Trait ArrayRef

Source
pub trait ArrayRef<'a>: Copy {
    type JsonRef: JsonRef<'a>;

    // Required methods
    fn len(self) -> usize;
    fn get(self, index: usize) -> Option<Self::JsonRef>;
    fn list(self) -> Vec<Self::JsonRef>;

    // Provided method
    fn is_empty(self) -> bool { ... }
}
Expand description

A trait for borrowed JSON arrays.

Required Associated Types§

Source

type JsonRef: JsonRef<'a>

The type of borrowed JSON values.

Required Methods§

Source

fn len(self) -> usize

Returns the length of the array.

Source

fn get(self, index: usize) -> Option<Self::JsonRef>

Returns the value at the given index.

Source

fn list(self) -> Vec<Self::JsonRef>

Returns all values in the array.

Provided Methods§

Source

fn is_empty(self) -> bool

Returns true if the array is empty.

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.

Implementations on Foreign Types§

Source§

impl<'a> ArrayRef<'a> for &'a Vec<Value>

Source§

type JsonRef = &'a Value

Source§

fn len(self) -> usize

Source§

fn get(self, index: usize) -> Option<Self::JsonRef>

Source§

fn list(self) -> Vec<Self::JsonRef>

Implementors§