mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00
sync: use usize instead of u32 for SemaphorePermit::split
(#6478)
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
This commit is contained in:
parent
bdf4c142c9
commit
90e20bcad3
@ -994,7 +994,9 @@ impl<'a> SemaphorePermit<'a> {
|
||||
/// Splits `n` permits from `self` and returns a new [`SemaphorePermit`] instance that holds `n` permits.
|
||||
///
|
||||
/// If there are insufficient permits and it's not possible to reduce by `n`, returns `None`.
|
||||
pub fn split(&mut self, n: u32) -> Option<Self> {
|
||||
pub fn split(&mut self, n: usize) -> Option<Self> {
|
||||
let n = u32::try_from(n).ok()?;
|
||||
|
||||
if n > self.permits {
|
||||
return None;
|
||||
}
|
||||
@ -1008,8 +1010,8 @@ impl<'a> SemaphorePermit<'a> {
|
||||
}
|
||||
|
||||
/// Returns the number of permits held by `self`.
|
||||
pub fn num_permits(&self) -> u32 {
|
||||
self.permits
|
||||
pub fn num_permits(&self) -> usize {
|
||||
self.permits as usize
|
||||
}
|
||||
}
|
||||
|
||||
@ -1047,7 +1049,9 @@ impl OwnedSemaphorePermit {
|
||||
/// # Note
|
||||
///
|
||||
/// It will clone the owned `Arc<Semaphore>` to construct the new instance.
|
||||
pub fn split(&mut self, n: u32) -> Option<Self> {
|
||||
pub fn split(&mut self, n: usize) -> Option<Self> {
|
||||
let n = u32::try_from(n).ok()?;
|
||||
|
||||
if n > self.permits {
|
||||
return None;
|
||||
}
|
||||
@ -1066,8 +1070,8 @@ impl OwnedSemaphorePermit {
|
||||
}
|
||||
|
||||
/// Returns the number of permits held by `self`.
|
||||
pub fn num_permits(&self) -> u32 {
|
||||
self.permits
|
||||
pub fn num_permits(&self) -> usize {
|
||||
self.permits as usize
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user