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 horizontal size.

Returns the vertical size.

Returns the length of underlying Vec.

Returns the slice of all values in the array.

Returns the reference of this array.

Returns the mutable slice of all values in the array.

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.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

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.

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.