/// Tries to acquire a certain amount of permits on a semaphore.
///
/// If acquiring the permits is successful, a [`GenericSemaphoreReleaser`]
/// will be returned, which will release all acquired permits automatically
/// when dropped.
///
/// Otherwise `None` will be returned.
Tries to acquire a certain amount of permits on a semaphore.
If acquiring the permits is successful, a [`GenericSemaphoreReleaser`]
will be returned, which will release all acquired permits automatically
when dropped.

Otherwise `None` will be returned.
Tries to acquire a certain amount of permits on a semaphore . If acquiring the permits is successful a [ ` GenericSemaphoreReleaser ` ] will be returned which will release all acquired permits automatically when dropped . Otherwise ` None ` will be returned .
pub fn try_acquire(
        &self,
        nr_permits: usize,
    ) -> Option<GenericSemaphoreReleaser<'_, MutexType>> {
        if self.state.lock().try_acquire_sync(nr_permits) {
            Some(GenericSemaphoreReleaser {
                semaphore: self,
                permits: nr_permits,
            })
        } else {
            None
        }
    }
pub fn try_acquire ( & self , nr_permits : usize , ) -> Option < GenericSemaphoreReleaser < ' _ , MutexType > > { if self . state . lock ( ) . try_acquire_sync ( nr_permits ) { Some ( GenericSemaphoreReleaser { semaphore : self , permits : nr_permits , } ) } else { None } }
Tries to acquire a certain amount of permits on a semaphore.
Tries to acquire a certain amount of permits on a semaphore .
&self
nr_permits
usize