Trait nom::lib::std::convert::AsMut1.0.0[][src]

pub trait AsMut<T> where
    T: ?Sized
{ pub fn as_mut(&mut self) -> &mut T; }
[]

Used to do a cheap mutable-to-mutable reference conversion.

This trait is similar to AsRef but used for converting between mutable references. If you need to do a costly conversion it is better to implement From with type &mut T or write a custom function.

Note: This trait must not fail. If the conversion can fail, use a dedicated method which returns an Option<T> or a Result<T, E>.

Generic Implementations

Examples

Using AsMut as trait bound for a generic function we can accept all mutable references that can be converted to type &mut T. Because Box<T> implements AsMut<T> we can write a function add_one that takes all arguments that can be converted to &mut u64. Because Box<T> implements AsMut<T>, add_one accepts arguments of type &mut Box<u64> as well:

fn add_one<T: AsMut<u64>>(num: &mut T) {
    *num.as_mut() += 1;
}

let mut boxed_num = Box::new(0);
add_one(&mut boxed_num);
assert_eq!(*boxed_num, 1);

Required methods

pub fn as_mut(&mut self) -> &mut T[src][]

Performs the conversion.

Implementors

impl AsMut<str> for str1.51.0[src][+]

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

impl<T> AsMut<[T]> for [T][src][+]

impl<T, const N: usize> AsMut<[T]> for [T; N][src][+]

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

impl<L, R> AsMut<str> for Either<L, R> where
    L: AsMut<str>,
    R: AsMut<str>, 

impl<L, R, Target> AsMut<Target> for Either<L, R> where
    L: AsMut<Target>,
    R: AsMut<Target>, 

impl<L, R, Target> AsMut<[Target]> for Either<L, R> where
    L: AsMut<[Target]>,
    R: AsMut<[Target]>, 

impl AsMut<[u8]> for MmapMut

impl AsMut<timespec> for TimeSpec

impl AsMut<timeval> for TimeVal

impl<A: Array> AsMut<[<A as Array>::Item]> for SmallVec<A>

impl AsMut<XAnyEvent> for XEvent

impl AsMut<XButtonEvent> for XEvent

impl AsMut<XCirculateEvent> for XEvent

impl AsMut<XCirculateRequestEvent> for XEvent

impl AsMut<XClientMessageEvent> for XEvent

impl AsMut<XColormapEvent> for XEvent

impl AsMut<XConfigureEvent> for XEvent

impl AsMut<XConfigureRequestEvent> for XEvent

impl AsMut<XCreateWindowEvent> for XEvent

impl AsMut<XCrossingEvent> for XEvent

impl AsMut<XDestroyWindowEvent> for XEvent

impl AsMut<XErrorEvent> for XEvent

impl AsMut<XExposeEvent> for XEvent

impl AsMut<XFocusChangeEvent> for XEvent

impl AsMut<XGenericEventCookie> for XEvent

impl AsMut<XGraphicsExposeEvent> for XEvent

impl AsMut<XGravityEvent> for XEvent

impl AsMut<XKeyEvent> for XEvent

impl AsMut<XKeymapEvent> for XEvent

impl AsMut<XMapEvent> for XEvent

impl AsMut<XMappingEvent> for XEvent

impl AsMut<XMapRequestEvent> for XEvent

impl AsMut<XMotionEvent> for XEvent

impl AsMut<XNoExposeEvent> for XEvent

impl AsMut<XPropertyEvent> for XEvent

impl AsMut<XReparentEvent> for XEvent

impl AsMut<XResizeRequestEvent> for XEvent

impl AsMut<XSelectionClearEvent> for XEvent

impl AsMut<XSelectionEvent> for XEvent

impl AsMut<XSelectionRequestEvent> for XEvent

impl AsMut<XUnmapEvent> for XEvent

impl AsMut<XVisibilityEvent> for XEvent

impl AsMut<[i8]> for ClientMessageData

impl AsMut<[u8]> for ClientMessageData

impl AsMut<[i16]> for ClientMessageData

impl AsMut<[u16]> for ClientMessageData

impl AsMut<[i64]> for ClientMessageData

impl AsMut<[u64]> for ClientMessageData

impl AsMut<XF86VidModeNotifyEvent> for XEvent

impl AsMut<XScreenSaverNotifyEvent> for XEvent

impl AsMut<XRRScreenChangeNotifyEvent> for XEvent

impl AsMut<XRRNotifyEvent> for XEvent

impl AsMut<XRROutputChangeNotifyEvent> for XEvent

impl AsMut<XRRCrtcChangeNotifyEvent> for XEvent

impl AsMut<XRROutputPropertyNotifyEvent> for XEvent

impl AsMut<XRRProviderChangeNotifyEvent> for XEvent

impl AsMut<XRRProviderPropertyNotifyEvent> for XEvent

impl AsMut<XRRResourceChangeNotifyEvent> for XEvent