Trait simd_json::prelude::MutableArray

source ·
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

Prelude to include needed traits Mutatability for array like values

Required Associated Types§

source

type Target

The type for Array Values

Required Methods§

source

fn push<V>(&mut self, v: V) -> Result<(), AccessError>
where V: Into<Self::Target>,

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.

source

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.

source

fn get_idx_mut(&mut self, i: usize) -> Option<&mut Self::Target>

Same as get_idx but returns a mutable ref instead

Provided Methods§

source

fn try_push<V>(&mut self, v: V)
where V: Into<Self::Target>,

Tries to push to a Value if as an Array. This function will have no effect if Value is of a different type

source

fn try_pop(&mut self) -> Option<Self::Target>

Tries to pop from a Value as an Array. if the Value is any other type None will always be returned

Object Safety§

This trait is not object safe.

Implementors§