Struct calamine::Range [] [src]

pub struct Range<T: CellType> { /* fields omitted */ }

A struct which represents a squared selection of cells

Methods

impl<T: CellType> Range<T>
[src]

Creates a new Range

When possible, prefer the more efficient Range::from_sparse

Get top left cell position (row, column)

Get bottom right cell position (row, column)

Get column width

Get column width

Get size

Is range empty

Set inner value from absolute position

Will try to resize inner structure if the value is out of bounds. For relative positions, use Index trait

Try to avoid this method as much as possible and prefer initializing the Range with from_sparce constructor.

Examples

use calamine::{Range, DataType};

let mut range = Range::new((0, 0), (5, 2));
assert_eq!(range.get_value((2, 1)), &DataType::Empty);
range.set_value((2, 1), DataType::Float(1.0))
    .expect("Cannot set value at position (2, 1)");
assert_eq!(range.get_value((2, 1)), &DataType::Float(1.0));

Get cell value from absolute position

For relative positions, use Index trait

Panics if indexes are out of range bounds

Get an iterator over inner rows

Examples

use calamine::{Range, DataType};

let range: Range<DataType> = Range::new((0, 0), (5, 2));
// with rows item row: &[DataType]
assert_eq!(range.rows().map(|r| r.len()).sum::<usize>(), 18);

Get an iterator over used cells only

Trait Implementations

impl<T: Debug + CellType> Debug for Range<T>
[src]

Formats the value using the given formatter.

impl<T: Default + CellType> Default for Range<T>
[src]

Returns the "default value" for a type. Read more

impl<T: Clone + CellType> Clone for Range<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: CellType> Index<usize> for Range<T>
[src]

The returned type after indexing

The method for the indexing (container[index]) operation

impl<T: CellType> Index<(usize, usize)> for Range<T>
[src]

The returned type after indexing

The method for the indexing (container[index]) operation

impl<T: CellType> IndexMut<usize> for Range<T>
[src]

The method for the mutable indexing (container[index]) operation

impl<T: CellType> IndexMut<(usize, usize)> for Range<T>
[src]

The method for the mutable indexing (container[index]) operation