Trait nom::lib::std::prelude::v1::rust_2015::AsRef1.0.0[][src]

pub trait AsRef<T> where
    T: ?Sized
{ pub fn as_ref(&self) -> &T

Notable traits for &'_ mut I

impl<'_, I> Iterator for &'_ mut I where
    I: Iterator + ?Sized
type Item = <I as Iterator>::Item;
; }
[]

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

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

AsRef has the same signature as Borrow, but Borrow is different in few aspects:

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

By using trait bounds we can accept arguments of different types as long as they can be converted to the specified type T.

For example: By creating a generic function that takes an AsRef<str> we express that we want to accept all references that can be converted to &str as an argument. Since both String and &str implement AsRef<str> we can accept both as input argument.

fn is_hello<T: AsRef<str>>(s: T) {
   assert_eq!("hello", s.as_ref());
}

let s = "hello";
is_hello(s);

let s = "hello".to_string();
is_hello(s);

Required methods

pub fn as_ref(&self) -> &T

Notable traits for &'_ mut I

impl<'_, I> Iterator for &'_ mut I where
    I: Iterator + ?Sized
type Item = <I as Iterator>::Item;
[src][]

Performs the conversion.

Implementations on Foreign Types

impl AsRef<Path> for str[src]

impl AsRef<OsStr> for Path[src]

impl<'_> AsRef<OsStr> for Iter<'_>[src]

impl<'_> AsRef<OsStr> for Component<'_>[src]

impl<'_> AsRef<Path> for Iter<'_>[src]

impl AsRef<OsStr> for str[src]

impl AsRef<OsStr> for OsStr[src]

impl<'_> AsRef<Path> for Components<'_>[src]

impl AsRef<Path> for OsString[src]

impl<'_> AsRef<Path> for Component<'_>[src]

impl AsRef<OsStr> for PathBuf[src]

impl AsRef<OsStr> for OsString[src]

impl AsRef<CStr> for CStr[src]

impl<'_> AsRef<OsStr> for Components<'_>[src]

impl AsRef<Path> for Path[src]

impl AsRef<Path> for PathBuf[src]

impl AsRef<Path> for OsStr[src]

impl AsRef<CStr> for CString[src]

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

impl AsRef<[u8]> for str[src]

impl<T> AsRef<[T]> for [T][src]

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

impl AsRef<str> for str[src]

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

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

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

Implementors

impl AsRef<[u8]> for String[src]

impl AsRef<str> for String[src]

impl AsRef<OsStr> for String[src]

impl AsRef<Path> for String[src]

impl<'_> AsRef<Path> for Cow<'_, OsStr>1.8.0[src]

impl<'_, T> AsRef<[T]> for nom::lib::std::slice::Iter<'_, T>1.13.0[src]

impl<'_, T> AsRef<[T]> for IterMut<'_, T>1.53.0[src]

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

impl<'a, T, A> AsRef<[T]> for Drain<'a, T, A> where
    A: Allocator
1.46.0[src]

impl<T, A> AsRef<[T]> for IntoIter<T, A> where
    A: Allocator
1.46.0[src]

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

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

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

impl<T, S> AsRef<[T; 3]> for Rgb<T, S>

impl<T, C: AsRef<[T; 3]>> AsRef<[T; 4]> for AlphaColor<T, C>

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

impl AsRef<Ident> for IdentString

impl AsRef<str> for IdentString

impl<T> AsRef<T> for SpannedValue<T>

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

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

impl<L, R> AsRef<Path> for Either<L, R> where
    L: AsRef<Path>,
    R: AsRef<Path>, 

impl<L, R> AsRef<OsStr> for Either<L, R> where
    L: AsRef<OsStr>,
    R: AsRef<OsStr>, 

impl<L, R> AsRef<CStr> for Either<L, R> where
    L: AsRef<CStr>,
    R: AsRef<CStr>, 

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

impl AsRef<dyn Fail + 'static> for Error

impl<T: AsRef<[u8]>> AsRef<[u8]> for Window<T>

impl<T, N> AsRef<[T]> for GenericArray<T, N> where
    N: ArrayLength<T>, 

impl<T> AsRef<[T; 1]> for GenericArray<T, U1>

impl<T> AsRef<[T; 2]> for GenericArray<T, U2>

impl<T> AsRef<[T; 3]> for GenericArray<T, U3>

impl<T> AsRef<[T; 4]> for GenericArray<T, U4>

impl<T> AsRef<[T; 5]> for GenericArray<T, U5>

impl<T> AsRef<[T; 6]> for GenericArray<T, U6>

impl<T> AsRef<[T; 7]> for GenericArray<T, U7>

impl<T> AsRef<[T; 8]> for GenericArray<T, U8>

impl<T> AsRef<[T; 9]> for GenericArray<T, U9>

impl<T> AsRef<[T; 10]> for GenericArray<T, U10>

impl<T> AsRef<[T; 11]> for GenericArray<T, U11>

impl<T> AsRef<[T; 12]> for GenericArray<T, U12>

impl<T> AsRef<[T; 13]> for GenericArray<T, U13>

impl<T> AsRef<[T; 14]> for GenericArray<T, U14>

impl<T> AsRef<[T; 15]> for GenericArray<T, U15>

impl<T> AsRef<[T; 16]> for GenericArray<T, U16>

impl<T> AsRef<[T; 17]> for GenericArray<T, U17>

impl<T> AsRef<[T; 18]> for GenericArray<T, U18>

impl<T> AsRef<[T; 19]> for GenericArray<T, U19>

impl<T> AsRef<[T; 20]> for GenericArray<T, U20>

impl<T> AsRef<[T; 21]> for GenericArray<T, U21>

impl<T> AsRef<[T; 22]> for GenericArray<T, U22>

impl<T> AsRef<[T; 23]> for GenericArray<T, U23>

impl<T> AsRef<[T; 24]> for GenericArray<T, U24>

impl<T> AsRef<[T; 25]> for GenericArray<T, U25>

impl<T> AsRef<[T; 26]> for GenericArray<T, U26>

impl<T> AsRef<[T; 27]> for GenericArray<T, U27>

impl<T> AsRef<[T; 28]> for GenericArray<T, U28>

impl<T> AsRef<[T; 29]> for GenericArray<T, U29>

impl<T> AsRef<[T; 30]> for GenericArray<T, U30>

impl<T> AsRef<[T; 31]> for GenericArray<T, U31>

impl<T> AsRef<[T; 32]> for GenericArray<T, U32>

impl<N, S> AsRef<[N; 1]> for Matrix<N, U1, U1, S> where
    N: Scalar,
    S: ContiguousStorage<N, U1, U1>, 

impl<N, S> AsRef<[N; 2]> for Matrix<N, U1, U2, S> where
    N: Scalar,
    S: ContiguousStorage<N, U1, U2>, 

impl<N, S> AsRef<[N; 3]> for Matrix<N, U1, U3, S> where
    N: Scalar,
    S: ContiguousStorage<N, U1, U3>, 

impl<N, S> AsRef<[N; 4]> for Matrix<N, U1, U4, S> where
    N: Scalar,
    S: ContiguousStorage<N, U1, U4>, 

impl<N, S> AsRef<[N; 5]> for Matrix<N, U1, U5, S> where
    N: Scalar,
    S: ContiguousStorage<N, U1, U5>, 

impl<N, S> AsRef<[N; 6]> for Matrix<N, U1, U6, S> where
    N: Scalar,
    S: ContiguousStorage<N, U1, U6>, 

impl<N, S> AsRef<[N; 7]> for Matrix<N, U1, U7, S> where
    N: Scalar,
    S: ContiguousStorage<N, U1, U7>, 

impl<N, S> AsRef<[N; 8]> for Matrix<N, U1, U8, S> where
    N: Scalar,
    S: ContiguousStorage<N, U1, U8>, 

impl<N, S> AsRef<[N; 9]> for Matrix<N, U1, U9, S> where
    N: Scalar,
    S: ContiguousStorage<N, U1, U9>, 

impl<N, S> AsRef<[N; 10]> for Matrix<N, U1, U10, S> where
    N: Scalar,
    S: ContiguousStorage<N, U1, U10>, 

impl<N, S> AsRef<[N; 11]> for Matrix<N, U1, U11, S> where
    N: Scalar,
    S: ContiguousStorage<N, U1, U11>, 

impl<N, S> AsRef<[N; 12]> for Matrix<N, U1, U12, S> where
    N: Scalar,
    S: ContiguousStorage<N, U1, U12>, 

impl<N, S> AsRef<[N; 13]> for Matrix<N, U1, U13, S> where
    N: Scalar,
    S: ContiguousStorage<N, U1, U13>, 

impl<N, S> AsRef<[N; 14]> for Matrix<N, U1, U14, S> where
    N: Scalar,
    S: ContiguousStorage<N, U1, U14>, 

impl<N, S> AsRef<[N; 15]> for Matrix<N, U1, U15, S> where
    N: Scalar,
    S: ContiguousStorage<N, U1, U15>, 

impl<N, S> AsRef<[N; 16]> for Matrix<N, U1, U16, S> where
    N: Scalar,
    S: ContiguousStorage<N, U1, U16>, 

impl<N, S> AsRef<[N; 2]> for Matrix<N, U2, U1, S> where
    N: Scalar,
    S: ContiguousStorage<N, U2, U1>, 

impl<N, S> AsRef<[N; 3]> for Matrix<N, U3, U1, S> where
    N: Scalar,
    S: ContiguousStorage<N, U3, U1>, 

impl<N, S> AsRef<[N; 4]> for Matrix<N, U4, U1, S> where
    N: Scalar,
    S: ContiguousStorage<N, U4, U1>, 

impl<N, S> AsRef<[N; 5]> for Matrix<N, U5, U1, S> where
    N: Scalar,
    S: ContiguousStorage<N, U5, U1>, 

impl<N, S> AsRef<[N; 6]> for Matrix<N, U6, U1, S> where
    N: Scalar,
    S: ContiguousStorage<N, U6, U1>, 

impl<N, S> AsRef<[N; 7]> for Matrix<N, U7, U1, S> where
    N: Scalar,
    S: ContiguousStorage<N, U7, U1>, 

impl<N, S> AsRef<[N; 8]> for Matrix<N, U8, U1, S> where
    N: Scalar,
    S: ContiguousStorage<N, U8, U1>, 

impl<N, S> AsRef<[N; 9]> for Matrix<N, U9, U1, S> where
    N: Scalar,
    S: ContiguousStorage<N, U9, U1>, 

impl<N, S> AsRef<[N; 10]> for Matrix<N, U10, U1, S> where
    N: Scalar,
    S: ContiguousStorage<N, U10, U1>, 

impl<N, S> AsRef<[N; 11]> for Matrix<N, U11, U1, S> where
    N: Scalar,
    S: ContiguousStorage<N, U11, U1>, 

impl<N, S> AsRef<[N; 12]> for Matrix<N, U12, U1, S> where
    N: Scalar,
    S: ContiguousStorage<N, U12, U1>, 

impl<N, S> AsRef<[N; 13]> for Matrix<N, U13, U1, S> where
    N: Scalar,
    S: ContiguousStorage<N, U13, U1>, 

impl<N, S> AsRef<[N; 14]> for Matrix<N, U14, U1, S> where
    N: Scalar,
    S: ContiguousStorage<N, U14, U1>, 

impl<N, S> AsRef<[N; 15]> for Matrix<N, U15, U1, S> where
    N: Scalar,
    S: ContiguousStorage<N, U15, U1>, 

impl<N, S> AsRef<[N; 16]> for Matrix<N, U16, U1, S> where
    N: Scalar,
    S: ContiguousStorage<N, U16, U1>, 

impl<N: Scalar, S> AsRef<[[N; 2]; 2]> for Matrix<N, U2, U2, S> where
    S: ContiguousStorage<N, U2, U2>, 

impl<N: Scalar, S> AsRef<[[N; 2]; 3]> for Matrix<N, U2, U3, S> where
    S: ContiguousStorage<N, U2, U3>, 

impl<N: Scalar, S> AsRef<[[N; 2]; 4]> for Matrix<N, U2, U4, S> where
    S: ContiguousStorage<N, U2, U4>, 

impl<N: Scalar, S> AsRef<[[N; 2]; 5]> for Matrix<N, U2, U5, S> where
    S: ContiguousStorage<N, U2, U5>, 

impl<N: Scalar, S> AsRef<[[N; 2]; 6]> for Matrix<N, U2, U6, S> where
    S: ContiguousStorage<N, U2, U6>, 

impl<N: Scalar, S> AsRef<[[N; 3]; 2]> for Matrix<N, U3, U2, S> where
    S: ContiguousStorage<N, U3, U2>, 

impl<N: Scalar, S> AsRef<[[N; 3]; 3]> for Matrix<N, U3, U3, S> where
    S: ContiguousStorage<N, U3, U3>, 

impl<N: Scalar, S> AsRef<[[N; 3]; 4]> for Matrix<N, U3, U4, S> where
    S: ContiguousStorage<N, U3, U4>, 

impl<N: Scalar, S> AsRef<[[N; 3]; 5]> for Matrix<N, U3, U5, S> where
    S: ContiguousStorage<N, U3, U5>, 

impl<N: Scalar, S> AsRef<[[N; 3]; 6]> for Matrix<N, U3, U6, S> where
    S: ContiguousStorage<N, U3, U6>, 

impl<N: Scalar, S> AsRef<[[N; 4]; 2]> for Matrix<N, U4, U2, S> where
    S: ContiguousStorage<N, U4, U2>, 

impl<N: Scalar, S> AsRef<[[N; 4]; 3]> for Matrix<N, U4, U3, S> where
    S: ContiguousStorage<N, U4, U3>, 

impl<N: Scalar, S> AsRef<[[N; 4]; 4]> for Matrix<N, U4, U4, S> where
    S: ContiguousStorage<N, U4, U4>, 

impl<N: Scalar, S> AsRef<[[N; 4]; 5]> for Matrix<N, U4, U5, S> where
    S: ContiguousStorage<N, U4, U5>, 

impl<N: Scalar, S> AsRef<[[N; 4]; 6]> for Matrix<N, U4, U6, S> where
    S: ContiguousStorage<N, U4, U6>, 

impl<N: Scalar, S> AsRef<[[N; 5]; 2]> for Matrix<N, U5, U2, S> where
    S: ContiguousStorage<N, U5, U2>, 

impl<N: Scalar, S> AsRef<[[N; 5]; 3]> for Matrix<N, U5, U3, S> where
    S: ContiguousStorage<N, U5, U3>, 

impl<N: Scalar, S> AsRef<[[N; 5]; 4]> for Matrix<N, U5, U4, S> where
    S: ContiguousStorage<N, U5, U4>, 

impl<N: Scalar, S> AsRef<[[N; 5]; 5]> for Matrix<N, U5, U5, S> where
    S: ContiguousStorage<N, U5, U5>, 

impl<N: Scalar, S> AsRef<[[N; 5]; 6]> for Matrix<N, U5, U6, S> where
    S: ContiguousStorage<N, U5, U6>, 

impl<N: Scalar, S> AsRef<[[N; 6]; 2]> for Matrix<N, U6, U2, S> where
    S: ContiguousStorage<N, U6, U2>, 

impl<N: Scalar, S> AsRef<[[N; 6]; 3]> for Matrix<N, U6, U3, S> where
    S: ContiguousStorage<N, U6, U3>, 

impl<N: Scalar, S> AsRef<[[N; 6]; 4]> for Matrix<N, U6, U4, S> where
    S: ContiguousStorage<N, U6, U4>, 

impl<N: Scalar, S> AsRef<[[N; 6]; 5]> for Matrix<N, U6, U5, S> where
    S: ContiguousStorage<N, U6, U5>, 

impl<N: Scalar, S> AsRef<[[N; 6]; 6]> for Matrix<N, U6, U6, S> where
    S: ContiguousStorage<N, U6, U6>, 

impl<T> AsRef<T> for Unit<T>

impl<N: SimdRealField> AsRef<[N; 8]> for DualQuaternion<N>

impl<N: RealField> AsRef<dyn Shape<N> + 'static> for ShapeHandle<N>

impl AsRef<[u8]> for Literal

impl AsRef<Rotation> for Rotation

impl<T> AsRef<[T]> for Mesh<T>

impl<'a, T> AsRef<[T]> for MeshSlice<'a, T>

impl<T: RealField> AsRef<[Point<T, U2>]> for Polyline<T>

impl<'a, T: RealField> AsRef<[Point<T, U2>]> for PolylineSlice<'a, T>

impl<T: BaseNum> AsRef<[T; 4]> for Rect<T>

impl<T> AsRef<T> for LazyUpdate<T>

impl<'a, T: Clone> AsRef<T> for Property<'a, T>

impl<'a, T: Clone, R> AsRef<T> for RangedPropertyMut<'a, T, R>

impl<'a, T: Clone, R> AsRef<T> for RangedPropertyLastValueMut<'a, T, R>

impl<'a, T: Clone> AsRef<T> for PropertyLastValue<'a, T>

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

impl AsRef<XAnyEvent> for XEvent

impl AsRef<XButtonEvent> for XEvent

impl AsRef<XCirculateEvent> for XEvent

impl AsRef<XCirculateRequestEvent> for XEvent

impl AsRef<XClientMessageEvent> for XEvent

impl AsRef<XColormapEvent> for XEvent

impl AsRef<XConfigureEvent> for XEvent

impl AsRef<XConfigureRequestEvent> for XEvent

impl AsRef<XCreateWindowEvent> for XEvent

impl AsRef<XCrossingEvent> for XEvent

impl AsRef<XDestroyWindowEvent> for XEvent

impl AsRef<XErrorEvent> for XEvent

impl AsRef<XExposeEvent> for XEvent

impl AsRef<XFocusChangeEvent> for XEvent

impl AsRef<XGenericEventCookie> for XEvent

impl AsRef<XGraphicsExposeEvent> for XEvent

impl AsRef<XGravityEvent> for XEvent

impl AsRef<XKeyEvent> for XEvent

impl AsRef<XKeymapEvent> for XEvent

impl AsRef<XMapEvent> for XEvent

impl AsRef<XMappingEvent> for XEvent

impl AsRef<XMapRequestEvent> for XEvent

impl AsRef<XMotionEvent> for XEvent

impl AsRef<XNoExposeEvent> for XEvent

impl AsRef<XPropertyEvent> for XEvent

impl AsRef<XReparentEvent> for XEvent

impl AsRef<XResizeRequestEvent> for XEvent

impl AsRef<XSelectionClearEvent> for XEvent

impl AsRef<XSelectionEvent> for XEvent

impl AsRef<XSelectionRequestEvent> for XEvent

impl AsRef<XUnmapEvent> for XEvent

impl AsRef<XVisibilityEvent> for XEvent

impl AsRef<[i8]> for ClientMessageData

impl AsRef<[u8]> for ClientMessageData

impl AsRef<[i16]> for ClientMessageData

impl AsRef<[u16]> for ClientMessageData

impl AsRef<[i64]> for ClientMessageData

impl AsRef<[u64]> for ClientMessageData

impl AsRef<XF86VidModeNotifyEvent> for XEvent

impl AsRef<XRRScreenChangeNotifyEvent> for XEvent

impl AsRef<XRRNotifyEvent> for XEvent

impl AsRef<XRROutputChangeNotifyEvent> for XEvent

impl AsRef<XRRCrtcChangeNotifyEvent> for XEvent

impl AsRef<XRROutputPropertyNotifyEvent> for XEvent

impl AsRef<XRRProviderChangeNotifyEvent> for XEvent

impl AsRef<XRRProviderPropertyNotifyEvent> for XEvent

impl AsRef<XRRResourceChangeNotifyEvent> for XEvent

impl AsRef<XScreenSaverNotifyEvent> for XEvent