pub trait MutableArray {
type Target;
// Required methods
fn push<V>(&mut self, v: V) -> Result<(), AccessError>
where V: Into<Self::Target>;
fn pop(&mut self) -> Result<Option<Self::Target>, AccessError>;
fn get_idx_mut(&mut self, i: usize) -> Option<&mut Self::Target>;
// Provided methods
fn try_push<V>(&mut self, v: V)
where V: Into<Self::Target> { ... }
fn try_pop(&mut self) -> Option<Self::Target> { ... }
}
Expand description
Mutatability for array like values
Required Associated Types§
Required Methods§
sourcefn push<V>(&mut self, v: V) -> Result<(), AccessError>
fn push<V>(&mut self, v: V) -> Result<(), AccessError>
Pushes to this Value
as an Array
.
Will return an AccessError::NotAnArray
if called
on a Value
that isn’t an Array
- otherwise will
behave the same as Vec::push
§Errors
Will return Err
if self
is not an array.
sourcefn pop(&mut self) -> Result<Option<Self::Target>, AccessError>
fn pop(&mut self) -> Result<Option<Self::Target>, AccessError>
Pops from this Value
as an Array
.
Will return an AccessError::NotAnArray
if called
on a Value
that isn’t an Array
- otherwise will
behave the same as Vec::pop
§Errors
Will return Err
if self
is not an array.
sourcefn get_idx_mut(&mut self, i: usize) -> Option<&mut Self::Target>
fn get_idx_mut(&mut self, i: usize) -> Option<&mut Self::Target>
Same as get_idx
but returns a mutable ref instead
Provided Methods§
Object Safety§
This trait is not object safe.