Trait nom::lib::std::prelude::v1::rust_2021::Into 1.0.0[−][src]
pub trait Into<T> { pub fn into(self) -> T; }
A value-to-value conversion that consumes the input value. The
opposite of From
.
One should avoid implementing Into
and implement From
instead.
Implementing From
automatically provides one with an implementation of Into
thanks to the blanket implementation in the standard library.
Prefer using Into
over From
when specifying trait bounds on a generic function
to ensure that types that only implement Into
can be used as well.
Note: This trait must not fail. If the conversion can fail, use TryInto
.
Generic Implementations
From
<T> for U
impliesInto<U> for T
Into
is reflexive, which means thatInto<T> for T
is implemented
Implementing Into
for conversions to external types in old versions of Rust
Prior to Rust 1.41, if the destination type was not part of the current crate
then you couldn’t implement From
directly.
For example, take this code:
struct Wrapper<T>(Vec<T>); impl<T> From<Wrapper<T>> for Vec<T> { fn from(w: Wrapper<T>) -> Vec<T> { w.0 } }
This will fail to compile in older versions of the language because Rust’s orphaning rules
used to be a little bit more strict. To bypass this, you could implement Into
directly:
struct Wrapper<T>(Vec<T>); impl<T> Into<Vec<T>> for Wrapper<T> { fn into(self) -> Vec<T> { self.0 } }
It is important to understand that Into
does not provide a From
implementation
(as From
does with Into
). Therefore, you should always try to implement From
and then fall back to Into
if From
can’t be implemented.
Examples
String
implements Into
<
Vec
<
u8
>>
:
In order to express that we want a generic function to take all arguments that can be
converted to a specified type T
, we can use a trait bound of Into
<T>
.
For example: The function is_hello
takes all arguments that can be converted into a
Vec
<
u8
>
.
fn is_hello<T: Into<Vec<u8>>>(s: T) { let bytes = b"hello".to_vec(); assert_eq!(bytes, s.into()); } let s = "hello".to_string(); is_hello(s);
Required methods
Implementors
impl Into<Vec<BacktraceFrame, Global>> for Backtrace
impl Into<Vec<BacktraceFrame, Global>> for Backtrace
impl Into<Arrow> for [ArrowShape; 2]
impl Into<Arrow> for [ArrowShape; 2]
impl Into<Arrow> for [ArrowShape; 3]
impl Into<Arrow> for [ArrowShape; 3]
impl Into<Arrow> for [ArrowShape; 4]
impl Into<Arrow> for [ArrowShape; 4]
impl<L, R> Into<Result<R, L>> for Either<L, R>
impl<L, R> Into<Result<R, L>> for Either<L, R>
impl Into<u64> for Pointer
impl Into<u64> for Pointer
impl<'input, Endian> Into<&'input [u8]> for EndianSlice<'input, Endian> where
Endian: Endianity,
impl<'input, Endian> Into<&'input [u8]> for EndianSlice<'input, Endian> where
Endian: Endianity,
impl Into<Vec<Format, Global>> for MatFormat
impl Into<Vec<Format, Global>> for MatFormat
impl Into<Vec<Format, Global>> for Format
impl Into<Vec<Format, Global>> for Format
impl<A, B> Into<Option<Either<A, B>>> for EitherOrBoth<A, B>
impl<A, B> Into<Option<Either<A, B>>> for EitherOrBoth<A, B>
impl<N, S> Into<[N; 1]> for Matrix<N, U1, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U1>,
impl<N, S> Into<[N; 1]> for Matrix<N, U1, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U1>,
impl<N, S> Into<[N; 2]> for Matrix<N, U1, U2, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U2>,
impl<N, S> Into<[N; 2]> for Matrix<N, U1, U2, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U2>,
impl<N, S> Into<[N; 3]> for Matrix<N, U1, U3, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U3>,
impl<N, S> Into<[N; 3]> for Matrix<N, U1, U3, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U3>,
impl<N, S> Into<[N; 4]> for Matrix<N, U1, U4, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U4>,
impl<N, S> Into<[N; 4]> for Matrix<N, U1, U4, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U4>,
impl<N, S> Into<[N; 5]> for Matrix<N, U1, U5, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U5>,
impl<N, S> Into<[N; 5]> for Matrix<N, U1, U5, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U5>,
impl<N, S> Into<[N; 6]> for Matrix<N, U1, U6, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U6>,
impl<N, S> Into<[N; 6]> for Matrix<N, U1, U6, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U6>,
impl<N, S> Into<[N; 7]> for Matrix<N, U1, U7, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U7>,
impl<N, S> Into<[N; 7]> for Matrix<N, U1, U7, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U7>,
impl<N, S> Into<[N; 8]> for Matrix<N, U1, U8, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U8>,
impl<N, S> Into<[N; 8]> for Matrix<N, U1, U8, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U8>,
impl<N, S> Into<[N; 9]> for Matrix<N, U1, U9, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U9>,
impl<N, S> Into<[N; 9]> for Matrix<N, U1, U9, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U9>,
impl<N, S> Into<[N; 10]> for Matrix<N, U1, U10, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U10>,
impl<N, S> Into<[N; 10]> for Matrix<N, U1, U10, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U10>,
impl<N, S> Into<[N; 11]> for Matrix<N, U1, U11, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U11>,
impl<N, S> Into<[N; 11]> for Matrix<N, U1, U11, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U11>,
impl<N, S> Into<[N; 12]> for Matrix<N, U1, U12, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U12>,
impl<N, S> Into<[N; 12]> for Matrix<N, U1, U12, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U12>,
impl<N, S> Into<[N; 13]> for Matrix<N, U1, U13, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U13>,
impl<N, S> Into<[N; 13]> for Matrix<N, U1, U13, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U13>,
impl<N, S> Into<[N; 14]> for Matrix<N, U1, U14, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U14>,
impl<N, S> Into<[N; 14]> for Matrix<N, U1, U14, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U14>,
impl<N, S> Into<[N; 15]> for Matrix<N, U1, U15, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U15>,
impl<N, S> Into<[N; 15]> for Matrix<N, U1, U15, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U15>,
impl<N, S> Into<[N; 16]> for Matrix<N, U1, U16, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U16>,
impl<N, S> Into<[N; 16]> for Matrix<N, U1, U16, S> where
N: Scalar,
S: ContiguousStorage<N, U1, U16>,
impl<N, S> Into<[N; 2]> for Matrix<N, U2, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U2, U1>,
impl<N, S> Into<[N; 2]> for Matrix<N, U2, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U2, U1>,
impl<N, S> Into<[N; 3]> for Matrix<N, U3, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U3, U1>,
impl<N, S> Into<[N; 3]> for Matrix<N, U3, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U3, U1>,
impl<N, S> Into<[N; 4]> for Matrix<N, U4, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U4, U1>,
impl<N, S> Into<[N; 4]> for Matrix<N, U4, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U4, U1>,
impl<N, S> Into<[N; 5]> for Matrix<N, U5, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U5, U1>,
impl<N, S> Into<[N; 5]> for Matrix<N, U5, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U5, U1>,
impl<N, S> Into<[N; 6]> for Matrix<N, U6, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U6, U1>,
impl<N, S> Into<[N; 6]> for Matrix<N, U6, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U6, U1>,
impl<N, S> Into<[N; 7]> for Matrix<N, U7, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U7, U1>,
impl<N, S> Into<[N; 7]> for Matrix<N, U7, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U7, U1>,
impl<N, S> Into<[N; 8]> for Matrix<N, U8, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U8, U1>,
impl<N, S> Into<[N; 8]> for Matrix<N, U8, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U8, U1>,
impl<N, S> Into<[N; 9]> for Matrix<N, U9, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U9, U1>,
impl<N, S> Into<[N; 9]> for Matrix<N, U9, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U9, U1>,
impl<N, S> Into<[N; 10]> for Matrix<N, U10, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U10, U1>,
impl<N, S> Into<[N; 10]> for Matrix<N, U10, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U10, U1>,
impl<N, S> Into<[N; 11]> for Matrix<N, U11, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U11, U1>,
impl<N, S> Into<[N; 11]> for Matrix<N, U11, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U11, U1>,
impl<N, S> Into<[N; 12]> for Matrix<N, U12, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U12, U1>,
impl<N, S> Into<[N; 12]> for Matrix<N, U12, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U12, U1>,
impl<N, S> Into<[N; 13]> for Matrix<N, U13, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U13, U1>,
impl<N, S> Into<[N; 13]> for Matrix<N, U13, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U13, U1>,
impl<N, S> Into<[N; 14]> for Matrix<N, U14, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U14, U1>,
impl<N, S> Into<[N; 14]> for Matrix<N, U14, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U14, U1>,
impl<N, S> Into<[N; 15]> for Matrix<N, U15, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U15, U1>,
impl<N, S> Into<[N; 15]> for Matrix<N, U15, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U15, U1>,
impl<N, S> Into<[N; 16]> for Matrix<N, U16, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U16, U1>,
impl<N, S> Into<[N; 16]> for Matrix<N, U16, U1, S> where
N: Scalar,
S: ContiguousStorage<N, U16, U1>,
impl<N: Scalar, S> Into<[[N; 2]; 2]> for Matrix<N, U2, U2, S> where
S: ContiguousStorage<N, U2, U2>,
impl<N: Scalar, S> Into<[[N; 2]; 2]> for Matrix<N, U2, U2, S> where
S: ContiguousStorage<N, U2, U2>,
impl<N: Scalar, S> Into<[[N; 2]; 3]> for Matrix<N, U2, U3, S> where
S: ContiguousStorage<N, U2, U3>,
impl<N: Scalar, S> Into<[[N; 2]; 3]> for Matrix<N, U2, U3, S> where
S: ContiguousStorage<N, U2, U3>,
impl<N: Scalar, S> Into<[[N; 2]; 4]> for Matrix<N, U2, U4, S> where
S: ContiguousStorage<N, U2, U4>,
impl<N: Scalar, S> Into<[[N; 2]; 4]> for Matrix<N, U2, U4, S> where
S: ContiguousStorage<N, U2, U4>,
impl<N: Scalar, S> Into<[[N; 2]; 5]> for Matrix<N, U2, U5, S> where
S: ContiguousStorage<N, U2, U5>,
impl<N: Scalar, S> Into<[[N; 2]; 5]> for Matrix<N, U2, U5, S> where
S: ContiguousStorage<N, U2, U5>,
impl<N: Scalar, S> Into<[[N; 2]; 6]> for Matrix<N, U2, U6, S> where
S: ContiguousStorage<N, U2, U6>,
impl<N: Scalar, S> Into<[[N; 2]; 6]> for Matrix<N, U2, U6, S> where
S: ContiguousStorage<N, U2, U6>,
impl<N: Scalar, S> Into<[[N; 3]; 2]> for Matrix<N, U3, U2, S> where
S: ContiguousStorage<N, U3, U2>,
impl<N: Scalar, S> Into<[[N; 3]; 2]> for Matrix<N, U3, U2, S> where
S: ContiguousStorage<N, U3, U2>,
impl<N: Scalar, S> Into<[[N; 3]; 3]> for Matrix<N, U3, U3, S> where
S: ContiguousStorage<N, U3, U3>,
impl<N: Scalar, S> Into<[[N; 3]; 3]> for Matrix<N, U3, U3, S> where
S: ContiguousStorage<N, U3, U3>,
impl<N: Scalar, S> Into<[[N; 3]; 4]> for Matrix<N, U3, U4, S> where
S: ContiguousStorage<N, U3, U4>,
impl<N: Scalar, S> Into<[[N; 3]; 4]> for Matrix<N, U3, U4, S> where
S: ContiguousStorage<N, U3, U4>,
impl<N: Scalar, S> Into<[[N; 3]; 5]> for Matrix<N, U3, U5, S> where
S: ContiguousStorage<N, U3, U5>,
impl<N: Scalar, S> Into<[[N; 3]; 5]> for Matrix<N, U3, U5, S> where
S: ContiguousStorage<N, U3, U5>,
impl<N: Scalar, S> Into<[[N; 3]; 6]> for Matrix<N, U3, U6, S> where
S: ContiguousStorage<N, U3, U6>,
impl<N: Scalar, S> Into<[[N; 3]; 6]> for Matrix<N, U3, U6, S> where
S: ContiguousStorage<N, U3, U6>,
impl<N: Scalar, S> Into<[[N; 4]; 2]> for Matrix<N, U4, U2, S> where
S: ContiguousStorage<N, U4, U2>,
impl<N: Scalar, S> Into<[[N; 4]; 2]> for Matrix<N, U4, U2, S> where
S: ContiguousStorage<N, U4, U2>,
impl<N: Scalar, S> Into<[[N; 4]; 3]> for Matrix<N, U4, U3, S> where
S: ContiguousStorage<N, U4, U3>,
impl<N: Scalar, S> Into<[[N; 4]; 3]> for Matrix<N, U4, U3, S> where
S: ContiguousStorage<N, U4, U3>,
impl<N: Scalar, S> Into<[[N; 4]; 4]> for Matrix<N, U4, U4, S> where
S: ContiguousStorage<N, U4, U4>,
impl<N: Scalar, S> Into<[[N; 4]; 4]> for Matrix<N, U4, U4, S> where
S: ContiguousStorage<N, U4, U4>,
impl<N: Scalar, S> Into<[[N; 4]; 5]> for Matrix<N, U4, U5, S> where
S: ContiguousStorage<N, U4, U5>,
impl<N: Scalar, S> Into<[[N; 4]; 5]> for Matrix<N, U4, U5, S> where
S: ContiguousStorage<N, U4, U5>,
impl<N: Scalar, S> Into<[[N; 4]; 6]> for Matrix<N, U4, U6, S> where
S: ContiguousStorage<N, U4, U6>,
impl<N: Scalar, S> Into<[[N; 4]; 6]> for Matrix<N, U4, U6, S> where
S: ContiguousStorage<N, U4, U6>,
impl<N: Scalar, S> Into<[[N; 5]; 2]> for Matrix<N, U5, U2, S> where
S: ContiguousStorage<N, U5, U2>,
impl<N: Scalar, S> Into<[[N; 5]; 2]> for Matrix<N, U5, U2, S> where
S: ContiguousStorage<N, U5, U2>,
impl<N: Scalar, S> Into<[[N; 5]; 3]> for Matrix<N, U5, U3, S> where
S: ContiguousStorage<N, U5, U3>,
impl<N: Scalar, S> Into<[[N; 5]; 3]> for Matrix<N, U5, U3, S> where
S: ContiguousStorage<N, U5, U3>,
impl<N: Scalar, S> Into<[[N; 5]; 4]> for Matrix<N, U5, U4, S> where
S: ContiguousStorage<N, U5, U4>,
impl<N: Scalar, S> Into<[[N; 5]; 4]> for Matrix<N, U5, U4, S> where
S: ContiguousStorage<N, U5, U4>,
impl<N: Scalar, S> Into<[[N; 5]; 5]> for Matrix<N, U5, U5, S> where
S: ContiguousStorage<N, U5, U5>,
impl<N: Scalar, S> Into<[[N; 5]; 5]> for Matrix<N, U5, U5, S> where
S: ContiguousStorage<N, U5, U5>,
impl<N: Scalar, S> Into<[[N; 5]; 6]> for Matrix<N, U5, U6, S> where
S: ContiguousStorage<N, U5, U6>,
impl<N: Scalar, S> Into<[[N; 5]; 6]> for Matrix<N, U5, U6, S> where
S: ContiguousStorage<N, U5, U6>,
impl<N: Scalar, S> Into<[[N; 6]; 2]> for Matrix<N, U6, U2, S> where
S: ContiguousStorage<N, U6, U2>,
impl<N: Scalar, S> Into<[[N; 6]; 2]> for Matrix<N, U6, U2, S> where
S: ContiguousStorage<N, U6, U2>,
impl<N: Scalar, S> Into<[[N; 6]; 3]> for Matrix<N, U6, U3, S> where
S: ContiguousStorage<N, U6, U3>,
impl<N: Scalar, S> Into<[[N; 6]; 3]> for Matrix<N, U6, U3, S> where
S: ContiguousStorage<N, U6, U3>,
impl<N: Scalar, S> Into<[[N; 6]; 4]> for Matrix<N, U6, U4, S> where
S: ContiguousStorage<N, U6, U4>,
impl<N: Scalar, S> Into<[[N; 6]; 4]> for Matrix<N, U6, U4, S> where
S: ContiguousStorage<N, U6, U4>,
impl<N: Scalar, S> Into<[[N; 6]; 5]> for Matrix<N, U6, U5, S> where
S: ContiguousStorage<N, U6, U5>,
impl<N: Scalar, S> Into<[[N; 6]; 5]> for Matrix<N, U6, U5, S> where
S: ContiguousStorage<N, U6, U5>,
impl<N: Scalar, S> Into<[[N; 6]; 6]> for Matrix<N, U6, U6, S> where
S: ContiguousStorage<N, U6, U6>,
impl<N: Scalar, S> Into<[[N; 6]; 6]> for Matrix<N, U6, U6, S> where
S: ContiguousStorage<N, U6, U6>,
impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: ContiguousStorage<N, R, C>> Into<&'a [N]> for &'a Matrix<N, R, C, S>
impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: ContiguousStorage<N, R, C>> Into<&'a [N]> for &'a Matrix<N, R, C, S>
impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: ContiguousStorageMut<N, R, C>> Into<&'a mut [N]> for &'a mut Matrix<N, R, C, S>
impl<'a, N: Scalar + Copy, R: Dim, C: Dim, S: ContiguousStorageMut<N, R, C>> Into<&'a mut [N]> for &'a mut Matrix<N, R, C, S>
impl<N, R: Dim, C: Dim> Into<Vec<N, Global>> for VecStorage<N, R, C>
impl<N, R: Dim, C: Dim> Into<Vec<N, Global>> for VecStorage<N, R, C>
impl<T> Into<(T, T)> for Ratio<T>
impl<T> Into<(T, T)> for Ratio<T>
impl<T: Zero> Into<Option<T>> for NotZero<T>
impl<T: Zero> Into<Option<T>> for NotZero<T>
impl<'a> Into<&'a [u32; 4]> for &'a vec128_storage
impl<'a> Into<&'a [u32; 4]> for &'a vec128_storage
impl Into<vec128_storage> for [u32; 4]
impl Into<vec128_storage> for [u32; 4]
impl Into<vec256_storage> for [u64; 4]
impl Into<vec256_storage> for [u64; 4]
impl Into<[u32; 4]> for vec128_storage
impl Into<[u32; 4]> for vec128_storage
impl Into<[u64; 2]> for vec128_storage
impl Into<[u64; 2]> for vec128_storage
impl Into<[u128; 1]> for vec128_storage
impl Into<[u128; 1]> for vec128_storage
impl Into<[u32; 8]> for vec256_storage
impl Into<[u32; 8]> for vec256_storage
impl Into<[u64; 4]> for vec256_storage
impl Into<[u64; 4]> for vec256_storage
impl Into<[u128; 2]> for vec256_storage
impl Into<[u128; 2]> for vec256_storage
impl Into<[u32; 16]> for vec512_storage
impl Into<[u32; 16]> for vec512_storage
impl Into<[u64; 8]> for vec512_storage
impl Into<[u64; 8]> for vec512_storage
impl Into<[u128; 4]> for vec512_storage
impl Into<[u128; 4]> for vec512_storage
impl Into<RotOrder> for RotOrder
impl Into<RotOrder> for RotOrder
impl<T> Into<Vec<T, Global>> for Mesh<T>
impl<T> Into<Vec<T, Global>> for Mesh<T>
impl<T> Into<(Vec<T, Global>, Vec<u32, Global>)> for Mesh<T>
impl<T> Into<(Vec<T, Global>, Vec<u32, Global>)> for Mesh<T>
impl<'a, T: Clone> Into<Data<'a, T>> for &'a Mesh<T>
impl<'a, T: Clone> Into<Data<'a, T>> for &'a Mesh<T>
impl<T> Into<Vec<Point<T, U2>, Global>> for Polyline<T> where
T: RealField,
impl<T> Into<Vec<Point<T, U2>, Global>> for Polyline<T> where
T: RealField,
impl<'a, T> Into<&'a [Point<T, U2>]> for PolylineSlice<'a, T> where
T: RealField,
impl<'a, T> Into<&'a [Point<T, U2>]> for PolylineSlice<'a, T> where
T: RealField,
impl Into<Rect> for Rect<i32>
impl Into<Rect> for Rect<i32>
impl Into<Rect> for Rect<u32>
impl Into<Rect> for Rect<u32>