Trait std::ops::DerefStable
[-]
[+]
[src]
pub trait Deref {
type Target;
fn deref(&'a self) -> &'a <Self as Deref>::Target;
}The Deref trait is used to specify the functionality of dereferencing
operations like *v.
Example
A struct with a single field which is accessible via dereferencing the struct.
#![feature(associated_types)] use std::ops::Deref; struct DerefExample<T> { value: T } impl<T> Deref for DerefExample<T> { type Target = T; fn deref<'a>(&'a self) -> &'a T { &self.value } } fn main() { let x = DerefExample { value: 'a' }; assert_eq!('a', *x); }#![feature(associated_types)] use std::ops::Deref; struct DerefExample<T> { value: T } impl<T> Deref for DerefExample<T> { type Target = T; fn deref<'a>(&'a self) -> &'a T { &self.value } } fn main() { let x = DerefExample { value: 'a' }; assert_eq!('a', *x); }
Required Methods
type Target
fn deref(&'a self) -> &'a <Self as Deref>::Target
The method called to dereference a value
Implementors
impl<T: Zeroable> Deref for NonZero<T>impl<'a, T> Deref for &'a Timpl<'a, T> Deref for &'a mut Timpl<'a, T, B> Deref for Cow<'a, T, B>impl<'b, T> Deref for Ref<'b, T>impl<'b, T> Deref for RefMut<'b, T>impl Deref for CStringimpl<'a> Deref for StdinReaderGuard<'a>impl<'id, T> Deref for IdRef<'id, T>impl Deref for Stringimpl<'a> Deref for DerefString<'a>impl<T> Deref for Vec<T>impl<'a, T> Deref for DerefVec<'a, T>impl<T> Deref for Box<T>impl<'mutex, T> Deref for MutexGuard<'mutex, T>impl<'rwlock, T> Deref for RwLockReadGuard<'rwlock, T>impl<'rwlock, T> Deref for RwLockWriteGuard<'rwlock, T>impl<T> Deref for Arc<T>impl<T> Deref for Rc<T>