1.0.0[][src]Trait af_lib::prelude::af_core::test::prelude::Deref

#[lang = "deref"]pub trait Deref {
    type Target: ?Sized;
#[must_use]    pub fn deref(&self) -> &Self::Target;
}

Used for immutable dereferencing operations, like *v.

In addition to being used for explicit dereferencing operations with the (unary) * operator in immutable contexts, Deref is also used implicitly by the compiler in many circumstances. This mechanism is called 'Deref coercion'. In mutable contexts, DerefMut is used.

Implementing Deref for smart pointers makes accessing the data behind them convenient, which is why they implement Deref. On the other hand, the rules regarding Deref and DerefMut were designed specifically to accommodate smart pointers. Because of this, Deref should only be implemented for smart pointers to avoid confusion.

For similar reasons, this trait should never fail. Failure during dereferencing can be extremely confusing when Deref is invoked implicitly.

More on Deref coercion

If T implements Deref<Target = U>, and x is a value of type T, then:

  • In immutable contexts, *x (where T is neither a reference nor a raw pointer) is equivalent to *Deref::deref(&x).
  • Values of type &T are coerced to values of type &U
  • T implicitly implements all the (immutable) methods of the type U.

For more details, visit the chapter in The Rust Programming Language as well as the reference sections on the dereference operator, method resolution and type coercions.

Examples

A struct with a single field which is accessible by dereferencing the struct.

use std::ops::Deref;

struct DerefExample<T> {
    value: T
}

impl<T> Deref for DerefExample<T> {
    type Target = T;

    fn deref(&self) -> &Self::Target {
        &self.value
    }
}

let x = DerefExample { value: 'a' };
assert_eq!('a', *x);

Associated Types

type Target: ?Sized[src]

The resulting type after dereferencing.

Loading content...

Required methods

#[must_use]pub fn deref(&self) -> &Self::Target[src]

Dereferences the value.

Loading content...

Implementations on Foreign Types

impl Deref for OsString[src]

type Target = OsStr

impl<'a> Deref for IoSlice<'a>[src]

type Target = [u8]

impl<T, F> Deref for SyncLazy<T, F> where
    F: FnOnce() -> T, 
[src]

type Target = T

impl Deref for CString[src]

type Target = CStr

impl Deref for PathBuf[src]

type Target = Path

impl<'_, T> Deref for MutexGuard<'_, T> where
    T: ?Sized
[src]

type Target = T

impl<'a> Deref for IoSliceMut<'a>[src]

type Target = [u8]

impl<'_, T> Deref for RwLockWriteGuard<'_, T> where
    T: ?Sized
[src]

type Target = T

impl<'_, T> Deref for RwLockReadGuard<'_, T> where
    T: ?Sized
[src]

type Target = T

impl<'_, T> Deref for &'_ mut T where
    T: ?Sized
[src]

type Target = T

impl<T, F> Deref for Lazy<T, F> where
    F: FnOnce() -> T, 
[src]

type Target = T

impl<'a, 'f> Deref for VaList<'a, 'f> where
    'f: 'a, 
[src]

type Target = VaListImpl<'f>

impl<'_, T> Deref for &'_ T where
    T: ?Sized
[src]

type Target = T

impl<T, A> Deref for Vec<T, A> where
    A: Allocator
[src]

type Target = [T]

impl<'_, T> Deref for PeekMut<'_, T> where
    T: Ord
[src]

type Target = T

impl<T, A> Deref for Box<T, A> where
    T: ?Sized,
    A: Allocator
[src]

type Target = T

impl Deref for String[src]

type Target = str

impl<T> Deref for CachePadded<T>

type Target = T

impl<'a, R, G, T> Deref for MappedReentrantMutexGuard<'a, R, G, T> where
    T: 'a + ?Sized,
    G: 'a + GetThreadId,
    R: 'a + RawMutex, 

type Target = T

impl<'a, R, T> Deref for RwLockUpgradableReadGuard<'a, R, T> where
    T: 'a + ?Sized,
    R: 'a + RawRwLockUpgrade, 

type Target = T

impl<'a, R, G, T> Deref for ReentrantMutexGuard<'a, R, G, T> where
    T: 'a + ?Sized,
    G: 'a + GetThreadId,
    R: 'a + RawMutex, 

type Target = T

impl<'a, R, T> Deref for RwLockWriteGuard<'a, R, T> where
    T: 'a + ?Sized,
    R: 'a + RawRwLock, 

type Target = T

impl<'a, R, T> Deref for MutexGuard<'a, R, T> where
    T: 'a + ?Sized,
    R: 'a + RawMutex, 

type Target = T

impl<'a, R, T> Deref for MappedRwLockWriteGuard<'a, R, T> where
    T: 'a + ?Sized,
    R: 'a + RawRwLock, 

type Target = T

impl<'a, R, T> Deref for MappedMutexGuard<'a, R, T> where
    T: 'a + ?Sized,
    R: 'a + RawMutex, 

type Target = T

impl<'a, R, T> Deref for MappedRwLockReadGuard<'a, R, T> where
    T: 'a + ?Sized,
    R: 'a + RawRwLock, 

type Target = T

impl<'a, R, T> Deref for RwLockReadGuard<'a, R, T> where
    T: 'a + ?Sized,
    R: 'a + RawRwLock, 

type Target = T

impl<T, F, S> Deref for ScopeGuard<T, F, S> where
    F: FnOnce(T),
    S: Strategy
[src]

type Target = T

impl<A> Deref for SmallVec<A> where
    A: Array, 

type Target = [<A as Array>::Item]

impl Deref for Literal

type Target = Vec<u8, Global>

impl<'a, K, V, S> Deref for Ref<'a, K, V, S> where
    S: BuildHasher,
    K: Eq + Hash

type Target = V

impl<'rwlock, T> Deref for RwLockReadGuard<'rwlock, T> where
    T: ?Sized

type Target = T

impl<'rwlock, T> Deref for RwLockWriteGuard<'rwlock, T> where
    T: ?Sized

type Target = T

impl<'a, K, V, S> Deref for RefMulti<'a, K, V, S> where
    S: BuildHasher,
    K: Eq + Hash

type Target = V

impl<'a, K, V, S> Deref for RefMutMulti<'a, K, V, S> where
    S: BuildHasher,
    K: Eq + Hash

type Target = V

impl<'a, K, V, S> Deref for RefMut<'a, K, V, S> where
    S: BuildHasher,
    K: Eq + Hash

type Target = V

impl<'rwlock, T> Deref for RwLockUpgradeableGuard<'rwlock, T> where
    T: ?Sized

type Target = T

impl<'a, K, S> Deref for RefMulti<'a, K, S> where
    S: BuildHasher,
    K: Eq + Hash

type Target = K

impl<'a, K, S> Deref for Ref<'a, K, S> where
    S: BuildHasher,
    K: Eq + Hash

type Target = K

impl Deref for BytesMut[src]

type Target = [u8]

impl Deref for Bytes[src]

type Target = [u8]

impl Deref for Digest

type Target = [u8; 16]

impl<T, N> Deref for GenericArray<T, N> where
    N: ArrayLength<T>, 

type Target = [T]

impl<A> Deref for ArrayVec<A> where
    A: Array, 

type Target = [<A as Array>::Item]

impl<A> Deref for TinyVec<A> where
    A: Array, 

type Target = [<A as Array>::Item]

impl<'s, T> Deref for SliceVec<'s, T>

type Target = [T]

impl<A, T> Deref for InlineArray<A, T>

type Target = [A]

impl<A, N> Deref for Chunk<A, N> where
    N: ChunkLength<A>, 

type Target = [A]

impl<'_, T> Deref for MutexGuard<'_, T> where
    T: ?Sized

type Target = T

impl<T> Deref for MutexGuardArc<T> where
    T: ?Sized

type Target = T

impl<'_, T> Deref for MutexGuard<'_, T> where
    T: ?Sized
[src]

type Target = T

impl<'_, T> Deref for Ref<'_, T>[src]

type Target = T

impl<T> Deref for OwnedMutexGuard<T> where
    T: ?Sized
[src]

type Target = T

impl<'_, T> Deref for RwLockWriteGuard<'_, T> where
    T: ?Sized
[src]

type Target = T

impl<'_, T> Deref for RwLockReadGuard<'_, T> where
    T: ?Sized
[src]

type Target = T

impl Deref for SslConnectorBuilder[src]

impl Deref for SslSession[src]

impl Deref for ConnectConfiguration[src]

type Target = SslRef

impl<T> Deref for Stack<T> where
    T: Stackable
[src]

type Target = StackRef<T>

impl Deref for X509Store[src]

type Target = X509StoreRef

impl Deref for X509StoreContext[src]

impl Deref for Pkcs7[src]

type Target = Pkcs7Ref

impl Deref for SslContext[src]

impl<T> Deref for EcKey<T>[src]

type Target = EcKeyRef<T>

impl Deref for EcGroup[src]

type Target = EcGroupRef

impl Deref for Pkcs12[src]

type Target = Pkcs12Ref

impl Deref for CmsContentInfo[src]

impl Deref for X509Extension[src]

impl Deref for BigNum[src]

type Target = BigNumRef

impl Deref for OcspCertId[src]

impl Deref for EcdsaSig[src]

type Target = EcdsaSigRef

impl Deref for OcspBasicResponse[src]

impl<T> Deref for X509LookupMethod<T>[src]

impl Deref for OcspRequest[src]

impl Deref for GeneralName[src]

impl Deref for X509Object[src]

impl Deref for Asn1Object[src]

impl Deref for X509NameEntry[src]

impl Deref for OpensslStringRef[src]

type Target = str

impl Deref for X509VerifyParam[src]

impl Deref for X509Algorithm[src]

impl Deref for X509Name[src]

type Target = X509NameRef

impl Deref for Conf[src]

type Target = ConfRef

impl<T> Deref for Dh<T>[src]

type Target = DhRef<T>

impl Deref for SrtpProtectionProfile[src]

impl Deref for Asn1Integer[src]

impl Deref for X509Req[src]

type Target = X509ReqRef

impl Deref for DigestBytes[src]

type Target = [u8]

impl Deref for X509StoreBuilder[src]

impl Deref for SslCipher[src]

type Target = SslCipherRef

impl Deref for Asn1Time[src]

type Target = Asn1TimeRef

impl Deref for Ssl[src]

type Target = SslRef

impl Deref for OcspOneReq[src]

impl Deref for BigNumContext[src]

impl<T> Deref for PKey<T>[src]

type Target = PKeyRef<T>

impl Deref for Asn1BitString[src]

impl Deref for Asn1GeneralizedTime[src]

impl Deref for OpensslString[src]

impl<T> Deref for Rsa<T>[src]

type Target = RsaRef<T>

impl Deref for OcspResponse[src]

impl Deref for Asn1String[src]

impl Deref for EcPoint[src]

type Target = EcPointRef

impl Deref for SslAcceptorBuilder[src]

impl<T> Deref for X509Lookup<T>[src]

type Target = X509LookupRef<T>

impl<T> Deref for Dsa<T>[src]

type Target = DsaRef<T>

impl Deref for X509[src]

type Target = X509Ref

impl<'_, T> Deref for MutexGuard<'_, T> where
    T: ?Sized

type Target = T

impl<'_, T, U> Deref for MappedMutexGuard<'_, T, U> where
    T: ?Sized,
    U: ?Sized

type Target = U

impl<'_> Deref for WakerRef<'_>

type Target = Waker

impl<S> Deref for BlockingStream<S> where
    S: Unpin + Stream

type Target = S

impl<A> Deref for SmallString<A> where
    A: Array<Item = u8>, 

type Target = str

impl<T> Deref for Values<T>

type Target = [T]

impl Deref for BytesMut[src]

type Target = [u8]

impl Deref for Bytes[src]

type Target = [u8]

impl<T> Deref for OwnedMutexGuard<T> where
    T: ?Sized
[src]

type Target = T

impl<'_, T> Deref for MutexGuard<'_, T> where
    T: ?Sized
[src]

type Target = T

impl<'_, T> Deref for RwLockWriteGuard<'_, T> where
    T: ?Sized
[src]

type Target = T

impl<'_, T> Deref for Ref<'_, T>[src]

type Target = T

impl<'_, T> Deref for RwLockReadGuard<'_, T> where
    T: ?Sized
[src]

type Target = T

impl Deref for UnixReady[src]

type Target = Ready

impl Deref for IoVec

type Target = [u8]

impl<'a, T> Deref for Locked<'a, T>[src]

type Target = T

impl<S> Deref for UniCase<S>[src]

type Target = S

impl<S> Deref for Ascii<S>[src]

type Target = S

impl<'input, Endian> Deref for EndianSlice<'input, Endian> where
    Endian: Endianity, 

type Target = [u8]

Loading content...

Implementors

impl Deref for SharedString[src]

type Target = str

impl Deref for ClientInitGuard

type Target = Client

impl<'_, B> Deref for Cow<'_, B> where
    B: ToOwned + ?Sized
[src]

type Target = B

impl<'_, T> Deref for af_lib::prelude::af_core::test::prelude::cell::Ref<'_, T> where
    T: ?Sized
[src]

type Target = T

impl<'_, T> Deref for af_lib::prelude::af_core::test::prelude::cell::RefMut<'_, T> where
    T: ?Sized
[src]

type Target = T

impl<L, R> Deref for Either<L, R> where
    L: Deref,
    R: Deref<Target = <L as Deref>::Target>, 
[src]

type Target = <L as Deref>::Target

impl<P> Deref for Pin<P> where
    P: Deref
[src]

type Target = <P as Deref>::Target

impl<T> Deref for AssertUnwindSafe<T>[src]

type Target = T

impl<T> Deref for Arc<T> where
    T: ?Sized
[src]

type Target = T

impl<T> Deref for ManuallyDrop<T> where
    T: ?Sized
[src]

type Target = T

impl<T> Deref for Rc<T> where
    T: ?Sized
[src]

type Target = T

impl<T, E> Deref for TryJoin<T, E>[src]

type Target = Join<Result<T, E>>

impl<T, F> Deref for af_lib::lazy::Lazy<T, F> where
    F: FnOnce() -> T, 

type Target = T

impl<T, F> Deref for af_lib::prelude::Lazy<T, F> where
    F: FnOnce() -> T, 

type Target = T

Loading content...