Enum gridly::grid::BoundsError
source · pub enum BoundsError {
Row(RowRangeError),
Column(ColumnRangeError),
Both {
row: RowRangeError,
column: ColumnRangeError,
},
}
Expand description
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§
Row(RowRangeError)
The location’s Row
was out of bounds.
Column(ColumnRangeError)
The location’s Column
was out of bounds.
Both
Implementations§
source§impl BoundsError
impl BoundsError
sourcepub fn row(&self) -> Option<&RowRangeError>
pub fn row(&self) -> Option<&RowRangeError>
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)
);
sourcepub fn column(&self) -> Option<&ColumnRangeError>
pub fn column(&self) -> Option<&ColumnRangeError>
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§
source§impl Clone for BoundsError
impl Clone for BoundsError
source§fn clone(&self) -> BoundsError
fn clone(&self) -> BoundsError
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for BoundsError
impl Debug for BoundsError
source§impl Display for BoundsError
impl Display for BoundsError
source§impl From<RangeError<Column>> for BoundsError
impl From<RangeError<Column>> for BoundsError
source§fn from(err: ColumnRangeError) -> Self
fn from(err: ColumnRangeError) -> Self
Converts to this type from the input type.
source§impl From<RangeError<Row>> for BoundsError
impl From<RangeError<Row>> for BoundsError
source§fn from(err: RowRangeError) -> Self
fn from(err: RowRangeError) -> Self
Converts to this type from the input type.
source§impl PartialEq for BoundsError
impl PartialEq for BoundsError
source§fn eq(&self, other: &BoundsError) -> bool
fn eq(&self, other: &BoundsError) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Copy for BoundsError
impl Eq for BoundsError
impl StructuralEq for BoundsError
impl StructuralPartialEq for BoundsError
Auto Trait Implementations§
impl RefUnwindSafe for BoundsError
impl Send for BoundsError
impl Sync for BoundsError
impl Unpin for BoundsError
impl UnwindSafe for BoundsError
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more