[][src]Enum gridly::grid::BoundsError

pub enum BoundsError {
    Row(RowRangeError),
    Column(ColumnRangeError),
    Both {
        row: RowRangeError,
        column: ColumnRangeError,
    },
}

An out-of-bounds error for a Location on a grid

This error is returned by methods that perform bounds checking to indicate a failed bounds check. It includes the specific boundary or boundaries that were violated.

Variants

The location's Row was out of bounds.

The location's Column was out of bounds.

Both

Both the Row and the Column were out of bounds.

Fields of Both

row: RowRangeErrorcolumn: ColumnRangeError

Methods

impl BoundsError[src]

pub fn row(&self) -> Option<&RowRangeError>[src]

The row component of the boundary error, if applicable.

use gridly::prelude::*;

let row_error = RowRangeError::TooLow(Row(0));
let col_error = ColumnRangeError::TooLow(Column(0));

assert_eq!(BoundsError::Row(row_error).row(), Some(&row_error));
assert_eq!(BoundsError::Column(col_error).row(), None);
assert_eq!(
    BoundsError::Both{row: row_error, column: col_error}.row(), Some(&row_error)
);

pub fn column(&self) -> Option<&ColumnRangeError>[src]

The column component of the boundary error, if applicable.

use gridly::prelude::*;

let row_error = RowRangeError::TooLow(Row(0));
let col_error = ColumnRangeError::TooLow(Column(0));

assert_eq!(BoundsError::Row(row_error).column(), None);
assert_eq!(BoundsError::Column(col_error).column(), Some(&col_error));
assert_eq!(
    BoundsError::Both{row: row_error, column: col_error}.column(), Some(&col_error)
);

Trait Implementations

impl Eq for BoundsError[src]

impl Clone for BoundsError[src]

impl PartialEq<BoundsError> for BoundsError[src]

impl From<RangeError<Row>> for BoundsError[src]

impl From<RangeError<Column>> for BoundsError[src]

impl Copy for BoundsError[src]

impl Debug for BoundsError[src]

impl Display for BoundsError[src]

Auto Trait Implementations

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]