Trait nom::lib::std::ops::DerefMut1.0.0[][src]

pub trait DerefMut: Deref {
    pub fn deref_mut(&mut self) -> &mut Self::Target;
}
[]

Used for mutable dereferencing operations, like in *v = 1;.

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

Implementing DerefMut for smart pointers makes mutating the data behind them convenient, which is why they implement DerefMut. On the other hand, the rules regarding Deref and DerefMut were designed specifically to accommodate smart pointers. Because of this, DerefMut 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 DerefMut is invoked implicitly.

More on Deref coercion

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

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 modifiable by dereferencing the struct.

use std::ops::{Deref, DerefMut};

struct DerefMutExample<T> {
    value: T
}

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

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

impl<T> DerefMut for DerefMutExample<T> {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.value
    }
}

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

Required methods

pub fn deref_mut(&mut self) -> &mut Self::Target[src][]

Mutably dereferences the value.

Implementations on Foreign Types

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

impl DerefMut for OsString[src]

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

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

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

impl<P> DerefMut for Pin<P> where
    P: DerefMut,
    <P as Deref>::Target: Unpin
[src]

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

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

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

impl<'_, T> DerefMut for RefMut<'_, T> where
    T: ?Sized
[src]

Implementors

impl DerefMut for String1.3.0[src]

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

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

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

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

impl<T: ?Sized + Pointable> DerefMut for Owned<T>

impl<T> DerefMut for CachePadded<T>

impl<T: ?Sized> DerefMut for ShardedLockWriteGuard<'_, T>

impl<T> DerefMut for SpannedValue<T>

impl<L, R> DerefMut for Either<L, R> where
    L: DerefMut,
    R: DerefMut<Target = L::Target>, 

impl<S: Stream + Unpin> DerefMut for BlockingStream<S>

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

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

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

impl DerefMut for TranslationUnit

impl<'a> DerefMut for Blob<'a>

impl<P, Container> DerefMut for ImageBuffer<P, Container> where
    P: Pixel + 'static,
    P::Subpixel: 'static,
    Container: Deref<Target = [P::Subpixel]> + DerefMut

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

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

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

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

impl<N: Scalar, S> DerefMut for Matrix<N, U1, U1, S> where
    S: ContiguousStorageMut<N, U1, U1>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U2, U1, S> where
    S: ContiguousStorageMut<N, U2, U1>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U3, U1, S> where
    S: ContiguousStorageMut<N, U3, U1>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U4, U1, S> where
    S: ContiguousStorageMut<N, U4, U1>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U5, U1, S> where
    S: ContiguousStorageMut<N, U5, U1>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U6, U1, S> where
    S: ContiguousStorageMut<N, U6, U1>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U1, U2, S> where
    S: ContiguousStorageMut<N, U1, U2>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U1, U3, S> where
    S: ContiguousStorageMut<N, U1, U3>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U1, U4, S> where
    S: ContiguousStorageMut<N, U1, U4>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U1, U5, S> where
    S: ContiguousStorageMut<N, U1, U5>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U1, U6, S> where
    S: ContiguousStorageMut<N, U1, U6>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U2, U2, S> where
    S: ContiguousStorageMut<N, U2, U2>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U2, U3, S> where
    S: ContiguousStorageMut<N, U2, U3>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U2, U4, S> where
    S: ContiguousStorageMut<N, U2, U4>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U2, U5, S> where
    S: ContiguousStorageMut<N, U2, U5>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U2, U6, S> where
    S: ContiguousStorageMut<N, U2, U6>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U3, U2, S> where
    S: ContiguousStorageMut<N, U3, U2>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U3, U3, S> where
    S: ContiguousStorageMut<N, U3, U3>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U3, U4, S> where
    S: ContiguousStorageMut<N, U3, U4>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U3, U5, S> where
    S: ContiguousStorageMut<N, U3, U5>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U3, U6, S> where
    S: ContiguousStorageMut<N, U3, U6>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U4, U2, S> where
    S: ContiguousStorageMut<N, U4, U2>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U4, U3, S> where
    S: ContiguousStorageMut<N, U4, U3>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U4, U4, S> where
    S: ContiguousStorageMut<N, U4, U4>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U4, U5, S> where
    S: ContiguousStorageMut<N, U4, U5>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U4, U6, S> where
    S: ContiguousStorageMut<N, U4, U6>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U5, U2, S> where
    S: ContiguousStorageMut<N, U5, U2>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U5, U3, S> where
    S: ContiguousStorageMut<N, U5, U3>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U5, U4, S> where
    S: ContiguousStorageMut<N, U5, U4>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U5, U5, S> where
    S: ContiguousStorageMut<N, U5, U5>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U5, U6, S> where
    S: ContiguousStorageMut<N, U5, U6>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U6, U2, S> where
    S: ContiguousStorageMut<N, U6, U2>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U6, U3, S> where
    S: ContiguousStorageMut<N, U6, U3>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U6, U4, S> where
    S: ContiguousStorageMut<N, U6, U4>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U6, U5, S> where
    S: ContiguousStorageMut<N, U6, U5>, 

impl<N: Scalar, S> DerefMut for Matrix<N, U6, U6, S> where
    S: ContiguousStorageMut<N, U6, U6>, 

impl<N, R, C> DerefMut for ArrayStorage<N, R, C> where
    R: DimName,
    C: DimName,
    R::Value: Mul<C::Value>,
    Prod<R::Value, C::Value>: ArrayLength<N>, 

impl<N: Scalar> DerefMut for Point<N, U1> where
    DefaultAllocator: Allocator<N, U1>, 

impl<N: Scalar> DerefMut for Point<N, U2> where
    DefaultAllocator: Allocator<N, U2>, 

impl<N: Scalar> DerefMut for Point<N, U3> where
    DefaultAllocator: Allocator<N, U3>, 

impl<N: Scalar> DerefMut for Point<N, U4> where
    DefaultAllocator: Allocator<N, U4>, 

impl<N: Scalar> DerefMut for Point<N, U5> where
    DefaultAllocator: Allocator<N, U5>, 

impl<N: Scalar> DerefMut for Point<N, U6> where
    DefaultAllocator: Allocator<N, U6>, 

impl<N: Scalar + SimdValue> DerefMut for Quaternion<N>

impl<N: Scalar> DerefMut for Translation<N, U1> where
    DefaultAllocator: Allocator<N, U1>, 

impl<N: Scalar> DerefMut for Translation<N, U2> where
    DefaultAllocator: Allocator<N, U2>, 

impl<N: Scalar> DerefMut for Translation<N, U3> where
    DefaultAllocator: Allocator<N, U3>, 

impl<N: Scalar> DerefMut for Translation<N, U4> where
    DefaultAllocator: Allocator<N, U4>, 

impl<N: Scalar> DerefMut for Translation<N, U5> where
    DefaultAllocator: Allocator<N, U5>, 

impl<N: Scalar> DerefMut for Translation<N, U6> where
    DefaultAllocator: Allocator<N, U6>, 

impl<T, F: FnOnce() -> T> DerefMut for Lazy<T, F>

impl<T, F: FnOnce() -> T> DerefMut for Lazy<T, F>

impl<C> DerefMut for Matrix<C>

impl DerefMut for Literal

impl DerefMut for Selectable

impl DerefMut for SkeletonRef

impl DerefMut for SkeletonName

impl DerefMut for BoneBase

impl DerefMut for BoneName

impl DerefMut for RootMotionBone

impl DerefMut for BoneWeightsAndIndicesBuffer

impl DerefMut for ArmatureMatricesBuffer

impl DerefMut for ArmatureDualQuatsBuffer

impl<T> DerefMut for Parameter<T>

impl DerefMut for MaterialMultiRef

impl DerefMut for Name

impl DerefMut for SourcePath

impl DerefMut for LightAsCameraUBO

impl DerefMut for ProgramRef

impl DerefMut for StaticMap

impl DerefMut for GpuGeometryRef

impl DerefMut for GpuDebugGeometryRef

impl DerefMut for GeomToGpuGeomRef

impl DerefMut for VertexBuffer

impl DerefMut for IndicesBuffer

impl DerefMut for DebugNormals

impl DerefMut for ShadowGeometry

impl DerefMut for CameraUBO

impl DerefMut for LightingUBO

impl DerefMut for LightData

impl DerefMut for ModelMatricesData

impl DerefMut for AllModelMatricesData

impl DerefMut for StaticModelMatricesData

impl DerefMut for DynamicModelMatricesData

impl DerefMut for ModelMatricesBuffer

impl DerefMut for StaticModelMatricesBuffer

impl DerefMut for DynamicModelMatricesBuffer

impl DerefMut for AllModelMatricesBuffer

impl DerefMut for OpaqueSortedGeometry

impl DerefMut for TranslucentSortedGeometry

impl DerefMut for DebugSortedGeometry

impl DerefMut for DynamicShadowsSortedGeometry

impl DerefMut for StaticShadowsSortedGeometry

impl DerefMut for AllShadowsSortedGeometry

impl DerefMut for GeometryWithModelsIndex

impl DerefMut for SkinningUpToDate

impl DerefMut for PreviousTransformation

impl DerefMut for Viewport

impl<C> DerefMut for Camera<C>

impl<T: 'static + Clone> DerefMut for Geometry<T>

impl DerefMut for Submesh

impl DerefMut for Shape

impl DerefMut for Offset

impl DerefMut for CollisionHandle

impl DerefMut for DebugGeometry

impl DerefMut for Map

impl DerefMut for StaticMap

impl DerefMut for Speed

impl DerefMut for Velocity

impl DerefMut for Delta

impl<T> DerefMut for LazyUpdate<T>

impl<T> DerefMut for Lazy<T>

impl<T> DerefMut for ValueCache<T>

impl<T> DerefMut for Node<T>

impl<'a, T: 'a> DerefMut for NodeIdMut<'a, T>

impl<'a, T> DerefMut for SliceViewMut<'a, T>

impl<'a, T> DerefMut for ResMut<'a, T>

impl<'a, T: Component> DerefMut for Write<'a, T> where
    <<T as Component>::Storage as Storage<'a, T>>::GetMut: BorrowMut<<<T as Component>::Storage as Storage<'a, T>>::DerefTarget>,
    <T as Component>::Storage: Storage<'s, T>, 

impl<'a, T: Component> DerefMut for WriteOption<'a, T>

impl<'a, T: NToOneComponent<'a>, R: UnorderedData<'a>> DerefMut for Ref<'a, T, R>

impl<'a, T: OneToOneComponent<'a>, R: UnorderedData<'a>> DerefMut for URef<'a, T, R>

impl<'a, T, R> DerefMut for RefN<'a, T, R> where
    R: UnorderedData<'a>, 

impl<T, F, S> DerefMut for ScopeGuard<T, F, S> where
    F: FnOnce(T),
    S: Strategy

impl<A: Array> DerefMut for SmallVec<A>

impl DerefMut for Underscore

impl DerefMut for Add

impl DerefMut for And

impl DerefMut for At

impl DerefMut for Bang

impl DerefMut for Caret

impl DerefMut for Colon

impl DerefMut for Comma

impl DerefMut for Div

impl DerefMut for Dollar

impl DerefMut for Dot

impl DerefMut for Eq

impl DerefMut for Gt

impl DerefMut for Lt

impl DerefMut for Or

impl DerefMut for Pound

impl DerefMut for Question

impl DerefMut for Rem

impl DerefMut for Semi

impl DerefMut for Star

impl DerefMut for Sub

impl DerefMut for Tilde