MCPcopy Create free account
hub / github.com/PerroEngine/Perro / from_slice

Method from_slice

perro_source/core/perro_structs/src/structs/matrix/mod.rs:887–902  ·  view source on GitHub ↗
(slice: &[T])

Source from the content-addressed store, hash-verified

885 /// Returns `None` when `slice.len() != ROWS * COLS`.
886 #[inline]
887 pub fn from_slice(slice: &[T]) -> Option<Self>
888 where
889 T: Copy + Default,
890 {
891 if slice.len() != ROWS * COLS {
892 return None;
893 }
894
895 let mut rows = [[T::default(); COLS]; ROWS];
896 for r in 0..ROWS {
897 for c in 0..COLS {
898 rows[r][c] = slice[r * COLS + c];
899 }
900 }
901 Some(Self(rows))
902 }
903
904 /// Build from row-major flat vec.
905 ///

Callers

nothing calls this directly

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected