pub fn try_read(&self) -> Result<RwLockReadGuard<'_, T>, TryLockError> {
        match self.s.try_acquire(1) {
            Ok(permit) => permit,
            Err(TryAcquireError::NoPermits) => return Err(TryLockError(())),
            Err(TryAcquireError::Closed) => unreachable!(),
        }

        Ok(RwLockReadGuard {
            s: &self.s,
            data: self.c.get(),
            marker: marker::PhantomData,
        })
    }
/// Attempts to acquire this `RwLock` with shared read access.
///
/// If the access couldn't be acquired immediately, returns [`TryLockError`].
/// Otherwise, an RAII guard is returned which will release read access
/// when dropped.
///
/// [`TryLockError`]: TryLockError
///
/// # Examples
///
/// ```
/// use std::sync::Arc;
/// use tokio::sync::RwLock;
///
/// #[tokio::main]
/// async fn main() {
///     let lock = Arc::new(RwLock::new(1));
///     let c_lock = lock.clone();
///
///     let v = lock.try_read().unwrap();
///     assert_eq!(*v, 1);
///
///     tokio::spawn(async move {
///         // While main has an active read lock, we acquire one too.
///         let n = c_lock.read().await;
///         assert_eq!(*n, 1);
///     }).await.expect("The spawned task has panicked");
///
///     // Drop the guard when spawned task finishes.
///     drop(v);
/// }
/// ```
Attempts to acquire this `RwLock` with shared read access.
If the access couldn't be acquired immediately, returns [`TryLockError`].
Otherwise, an RAII guard is returned which will release read access
when dropped.


Attempts to acquire this ` RwLock ` with shared read access . If the access couldn ' t be acquired immediately returns [ ` TryLockError ` ] . Otherwise an RAII guard is returned which will release read access when dropped .
pub fn try_read(&self) -> Result<RwLockReadGuard<'_, T>, TryLockError> {
        match self.s.try_acquire(1) {
            Ok(permit) => permit,
            Err(TryAcquireError::NoPermits) => return Err(TryLockError(())),
            Err(TryAcquireError::Closed) => unreachable!(),
        }
        Ok(RwLockReadGuard {
            s: &self.s,
            data: self.c.get(),
            marker: marker::PhantomData,
        })
    }
pub fn try_read ( & self ) -> Result < RwLockReadGuard < ' _ , T > , TryLockError > { match self . s . try_acquire ( 1 ) { Ok ( permit ) => permit , Err ( TryAcquireError :: NoPermits ) => return Err ( TryLockError ( ( ) ) ) , Err ( TryAcquireError :: Closed ) => unreachable ! ( ) , } Ok ( RwLockReadGuard { s : & self . s , data : self . c . get ( ) , marker : marker :: PhantomData , } ) }
Attempts to acquire this `RwLock` with shared read access.
Attempts to acquire this ` RwLock ` with shared read access .
&self
examples
```
use std::sync::Arc;
use tokio::sync::RwLock.
` ` ` use std :: sync :: Arc ; use tokio :: sync :: RwLock .
[tokio::main]
async fn main() {
let lock = Arc::new(RwLock::new(1));
let c_lock = lock.clone().



:spawn(async move {
While main has an active read lock, we acquire one too.
let n = c_lock.read().await;
assert_eq!(*n, 1);
}).await.expect("The spawned task has panicked").

Drop the guard when spawned task finishes.
async fn main () { let lock = Arc :: new ( RwLock :: new ( 1 )) ; let c_lock = lock . clone () . : spawn ( async move { While main has an active read lock we acquire one too . let n = c_lock . read () . await ; assert_eq! ( * n 1 ) ; } ) . await . expect ( " The spawned task has panicked " ) . Drop the guard when spawned task finishes .