Add into_vec() method and format code

This commit is contained in:
Junfeng Liu 2021-05-25 15:12:41 +08:00
parent 5986be422c
commit 15a734751c

View file

@ -617,7 +617,12 @@ impl<T: Clone> Grid<T> {
/// assert_eq!(flat, &vec![1,2,3,4,5,6]);
/// ```
pub fn flatten(&self) -> &Vec<T> {
return &self.data
&self.data
}
/// Converts self into a vector without clones or allocation.
pub fn into_vec(self) -> Vec<T> {
self.data
}
}
@ -693,7 +698,6 @@ mod test {
grid.insert_col(3, vec![4, 5]);
}
#[test]
fn insert_row_at_end() {
let mut grid: Grid<u8> = Grid::from_vec(vec![1, 2, 3, 4], 2);