Add into_vec() method and format code
This commit is contained in:
parent
5986be422c
commit
15a734751c
1 changed files with 11 additions and 7 deletions
|
@ -617,7 +617,12 @@ impl<T: Clone> Grid<T> {
|
||||||
/// assert_eq!(flat, &vec![1,2,3,4,5,6]);
|
/// assert_eq!(flat, &vec![1,2,3,4,5,6]);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn flatten(&self) -> &Vec<T> {
|
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]);
|
grid.insert_col(3, vec![4, 5]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn insert_row_at_end() {
|
fn insert_row_at_end() {
|
||||||
let mut grid: Grid<u8> = Grid::from_vec(vec![1, 2, 3, 4], 2);
|
let mut grid: Grid<u8> = Grid::from_vec(vec![1, 2, 3, 4], 2);
|
||||||
|
|
Loading…
Reference in a new issue