simd_json::prelude

Trait 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>;

    // 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§

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.

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

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.

Implementors§