pub trait GridSetter: Grid {
// Required methods
unsafe fn replace_unchecked(
&mut self,
location: Location,
value: Self::Item,
) -> Self::Item;
unsafe fn set_unchecked(&mut self, location: Location, value: Self::Item);
// Provided methods
fn replace(
&mut self,
location: impl LocationLike,
value: Self::Item,
) -> Result<Self::Item, BoundsError> { ... }
fn set(
&mut self,
location: impl LocationLike,
value: Self::Item,
) -> Result<(), BoundsError> { ... }
}
Expand description
Required Methods§
Sourceunsafe fn replace_unchecked(
&mut self,
location: Location,
value: Self::Item,
) -> Self::Item
unsafe fn replace_unchecked( &mut self, location: Location, value: Self::Item, ) -> Self::Item
Replace the value at the given location
with value
, without
bounds checking location
. Returns the previous value in the grid.
Implementors of this method are allowed to skip bounds checking
location
. The safe interface to GridSetter
bounds checks its
arguments where necessary before calling this method.
§Safety
Callers must ensure that the location has been bounds-checked before
calling this method. The safe interface to Grid
automatically performs
this checking for you.
Sourceunsafe fn set_unchecked(&mut self, location: Location, value: Self::Item)
unsafe fn set_unchecked(&mut self, location: Location, value: Self::Item)
Replace the value at the given location
with value
, without bounds
checking location
.
Implementors of this method are allowed to skip bounds checking
location
. The safe interface to GridSetter
bounds checks its
arguments where necessary before calling this method.
§Safety
Callers must ensure that the location has been bounds-checked before
calling this method. The safe interface to Grid
automatically performs
this checking for you.
Provided Methods§
Sourcefn replace(
&mut self,
location: impl LocationLike,
value: Self::Item,
) -> Result<Self::Item, BoundsError>
fn replace( &mut self, location: impl LocationLike, value: Self::Item, ) -> Result<Self::Item, BoundsError>
Replace the value at the given location
with value
. Returns the
previous value in the grid, or an error if the location was out of
bounds.
Sourcefn set(
&mut self,
location: impl LocationLike,
value: Self::Item,
) -> Result<(), BoundsError>
fn set( &mut self, location: impl LocationLike, value: Self::Item, ) -> Result<(), BoundsError>
Set the value at the given location
in the grid. Returns an error
if the location was out of bounds.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.