summaryrefslogtreecommitdiffstats
path: root/src/grid/row.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/grid/row.rs')
-rw-r--r--src/grid/row.rs22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/grid/row.rs b/src/grid/row.rs
index ef27f040..0a58de97 100644
--- a/src/grid/row.rs
+++ b/src/grid/row.rs
@@ -14,9 +14,9 @@
//! Defines the Row type which makes up lines in the grid
+use std::cmp::{max, min};
use std::ops::{Index, IndexMut};
-use std::ops::{Range, RangeTo, RangeFrom, RangeFull, RangeToInclusive};
-use std::cmp::{min, max};
+use std::ops::{Range, RangeFrom, RangeFull, RangeTo, RangeToInclusive};
use std::slice;
use crate::grid::GridCell;
@@ -46,10 +46,7 @@ impl<T: PartialEq> PartialEq for Row<T> {
impl<T: Copy> Row<T> {
pub fn new(columns: Column, template: &T) -> Row<T> {
- Row {
- inner: vec![*template; *columns],
- occ: 0,
- }
+ Row { inner: vec![*template; *columns], occ: 0 }
}
pub fn grow(&mut self, cols: Column, template: &T) {
@@ -62,7 +59,7 @@ impl<T: Copy> Row<T> {
pub fn shrink(&mut self, cols: Column) -> Option<Vec<T>>
where
- T: GridCell
+ T: GridCell,
{
if self.inner.len() <= cols.0 {
return None;
@@ -96,10 +93,7 @@ impl<T: Copy> Row<T> {
impl<T> Row<T> {
#[inline]
pub fn from_vec(vec: Vec<T>, occ: usize) -> Row<T> {
- Row {
- inner: vec,
- occ,
- }
+ Row { inner: vec, occ }
}
#[inline]
@@ -121,7 +115,7 @@ impl<T> Row<T> {
#[inline]
pub fn append(&mut self, vec: &mut Vec<T>)
where
- T: GridCell
+ T: GridCell,
{
self.inner.append(vec);
self.occ = self.inner.iter().rposition(|c| !c.is_empty()).map(|i| i + 1).unwrap_or(0);
@@ -137,7 +131,7 @@ impl<T> Row<T> {
#[inline]
pub fn is_empty(&self) -> bool
where
- T: GridCell
+ T: GridCell,
{
self.inner.iter().all(|c| c.is_empty())
}
@@ -153,8 +147,8 @@ impl<T> Row<T> {
}
impl<'a, T> IntoIterator for &'a mut Row<T> {
- type Item = &'a mut T;
type IntoIter = slice::IterMut<'a, T>;
+ type Item = &'a mut T;
#[inline]
fn into_iter(self) -> slice::IterMut<'a, T> {