diff options
author | William Brown <william@blackhats.net.au> | 2016-03-25 08:40:54 +1000 |
---|---|---|
committer | William Brown <william@blackhats.net.au> | 2016-03-25 08:40:54 +1000 |
commit | 16f0470dbc4496fe5b90de433a03b9ff5affcf8a (patch) | |
tree | 5180dd3329ec2455d3f919857b0d0bcd42f60ed3 /src/row.rs | |
parent | 2d3ff462d8a5f584f5f25a4427ad766db37be5a1 (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.rs | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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>
|