summaryrefslogtreecommitdiffstats
path: root/src/row.rs
diff options
context:
space:
mode:
authorWilliam Brown <william@blackhats.net.au>2016-03-25 08:40:54 +1000
committerWilliam Brown <william@blackhats.net.au>2016-03-25 08:40:54 +1000
commit16f0470dbc4496fe5b90de433a03b9ff5affcf8a (patch)
tree5180dd3329ec2455d3f919857b0d0bcd42f60ed3 /src/row.rs
parent2d3ff462d8a5f584f5f25a4427ad766db37be5a1 (diff)
Add some iters for use with rows to make formatting cells a bit easier
Diffstat (limited to 'src/row.rs')
-rw-r--r--src/row.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/row.rs b/src/row.rs
index b4f7d7b..0e9e003 100644
--- a/src/row.rs
+++ b/src/row.rs
@@ -1,6 +1,7 @@
//! This module contains definition of table rows stuff
use std::io::{Write, Error};
use std::iter::FromIterator;
+use std::slice::{Iter, IterMut};
use std::ops::{Index, IndexMut};
use term::Terminal;
@@ -95,6 +96,16 @@ impl Row {
}
}
+ // You need to impl Iterator for these to work with for / map implicitly
+ // But there is a compiler warning when you do add the trait.
+ pub fn iter<'a>(&'a self) -> Iter<'a, Cell> {
+ self.cells.iter()
+ }
+
+ pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, Cell> {
+ self.cells.iter_mut()
+ }
+
/// Internal only
fn __print<T:Write+?Sized, F>(&self, out: &mut T, format: &TableFormat, col_width: &[usize], f: F) -> Result<(), Error>
where F: Fn(&Cell, &mut T, usize, usize, bool) -> Result<(), Error>