into
- Prefix for methods that convert
selfinto another type.
Consumes self, returns an owned value.
#![allow(unused)] fn main() { impl<T> Vec<T> { fn into_parts(self) -> (NonNull<T>, usize, usize); } impl<T> Cell<T> { fn into_inner(self) -> T; } }
- Prefix for a function that consumes an owned value and transforms it into a value of another type.
Not reinterpret cast! The data can be rearranged, reallocated, changed in any way, including losing information.
-
corollary to
From -
into_iterconsumes a collection (like a vec, or a btreeset, or a hashmap) and produces an iterator over owned values, unlikeiteranditer_mutwhich produce iterators over reference values. -
Ask the class: what will
Vec::into_raw_partsdo?