pub fn column_iter(
        &self,
        column_index: usize,
    ) -> Result<impl DoubleEndedIterator<Item = &T>, Error> {
        if column_index >= self.num_columns {
            return Err(Error::IndicesOutOfBounds(0, column_index));
        }
        Ok((0..self.column_len()).map(move |row_index| &self[(row_index, column_index)]))
    }
/// Returns an [`Iterator`] over references to all elements in the given
/// column. Returns an error if the index is out of bounds.
///
/// # Examples
///
/// ```
/// # use array2d::{Array2D, Error};
/// # fn main() -> Result<(), Error> {
/// let rows = vec![vec![1, 2, 3], vec![4, 5, 6]];
/// let array = Array2D::from_rows(&rows)?;
/// let mut column_iter = array.column_iter(1)?;
/// assert_eq!(column_iter.next(), Some(&2));
/// assert_eq!(column_iter.next(), Some(&5));
/// assert_eq!(column_iter.next(), None);
/// # Ok(())
/// # }
/// ```
///
/// [`Iterator`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html
Returns an [`Iterator`] over references to all elements in the given
column. Returns an error if the index is out of bounds.
Returns an [ ` Iterator ` ] over references to all elements in the given column . Returns an error if the index is out of bounds .
pub fn column_iter(
        &self,
        column_index: usize,
    ) -> Result<impl DoubleEndedIterator<Item = &T>, Error> {
        if column_index >= self.num_columns {
            return Err(Error::IndicesOutOfBounds(0, column_index));
        }
        Ok((0..self.column_len()).map(move |row_index| &self[(row_index, column_index)]))
    }
pub fn column_iter ( & self , column_index : usize , ) -> Result < impl DoubleEndedIterator < Item = & T > , Error > { if column_index >= self . num_columns { return Err ( Error :: IndicesOutOfBounds ( 0 , column_index ) ) ; } Ok ( ( 0 .. self . column_len ( ) ) . map ( move | row_index | & self [ ( row_index , column_index ) ] ) ) }
Returns an [`Iterator`] over references to all elements in the given
column.
Returns an [ ` Iterator ` ] over references to all elements in the given column .
&self
column_index
usize
&self
column_index
usize
examples
None
use array2d::{array2d, error};
None
fn main() -> result<(), error> {
let rows = vec![vec![1, 2, 3], vec![4, 5, 6]];
let array = Array2D::from_rows(&rows)?;
let mut column_iter = array.column_iter(1)?;
assert_eq!(column_iter.next(), Some(&2));
assert_eq!(column_iter.next(), Some(&5));
assert_eq!(column_iter.next(), None).
let rows = vec! [ vec! [ 1 2 3 ] vec! [ 4 5 6 ]] ; let array = Array2D :: from_rows ( &rows ) ? ; let mut column_iter = array . column_iter ( 1 ) ? ; assert_eq! ( column_iter . next () Some ( &2 )) ; assert_eq! ( column_iter . next () Some ( &5 )) ; assert_eq! ( column_iter . next () None ) .
ok(())
None
}
None