Struct lattice_graph::fixedvec2d::FixedVec2D [−][src]
pub struct FixedVec2D<T> { /* fields omitted */ }
Expand description
Raw fixed 2d vector. It has two axis, horizontal and vertical. Data is stored on one Vec
.
Horizontal size must not be 0.
Implementations
Creates a array2d with a vec.
Returns None
if h * v != vec.len()
Creates a FixedVec2D without initializing.
It is unsafe to use it so I recomend to use with MaybeUninit
or just use new
.
See assume_init
.
Creates a FixedVec2D with initializing from the function.
let array = FixedVec2D::new(NonZeroUsize::new(5).unwrap(), 2, |h, v| (h, v)); for i in 0..5 { for j in 0..2 { assert_eq!(array.ref_2d()[i][j], (i, j)); } }
Returns the mutable reference of this array.
Returns the underlying Vec
consuming this FixedVec2D
Assume init. Use this with new_uninit
.
let mut array = unsafe { FixedVec2D::<MaybeUninit<i32>>::new_uninit(NonZeroUsize::new(6).unwrap(),3) }; for i in 0..6{ for j in 0..3{ array.mut_2d()[i][j] = MaybeUninit::new((i + j) as i32); } } let array_init = unsafe { array.assume_init() };
Trait Implementations
Performs the conversion.
Auto Trait Implementations
impl<T> RefUnwindSafe for FixedVec2D<T> where
T: RefUnwindSafe,
impl<T> !Send for FixedVec2D<T>
impl<T> !Sync for FixedVec2D<T>
impl<T> Unpin for FixedVec2D<T>
impl<T> UnwindSafe for FixedVec2D<T> where
T: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
get wheter the type is const generic wrapper.
Compare self to key
and return true
if they are equal.