List

Struct List 

Source
pub struct List<'a> { /* private fields */ }
Expand description

Container that stores its elements sequentially and provides get by position access

Implementations§

Source§

impl<'a> List<'a>

Source

pub fn add_value<'c, 'p: 'c, 'd>( &'p mut self, value: impl AsValue<'d>, ) -> Result<Value<'c>, Error>

Adds new value to this list

Source

pub fn as_bytes(&self) -> &[u8]

Returns slice of bytes representing current document.

It’s guaranteed to be subslice of initial buffer and for root document it will starting at 0.

So by taking it’s len you can get how many bytes in buffer are used

Source

pub fn count(&self) -> usize

Returns number of elements in this list

Source

pub fn empty() -> List<'static>

Returns new empty list

List is read only so no new elements can be added to it

Source

pub fn empty_mut(allocation: impl Into<Allocation<'a>>) -> Result<Self, Error>

Creates a new list that uses given allocation for storage

Source

pub fn get(&self, pos: usize) -> Option<Value<'_>>

Get value at position

Source

pub fn iter(&self) -> impl Iterator<Item = Value<'_>>

Iterate over elements of this list

Trait Implementations§

Source§

impl<'a> Debug for List<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for List<'a>

Source§

fn eq(&self, other: &List<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> TryFrom<Value<'a>> for List<'a>

Source§

type Error = Value<'a>

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value<'a>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> Eq for List<'a>

Source§

impl<'a> StructuralPartialEq for List<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for List<'a>

§

impl<'a> RefUnwindSafe for List<'a>

§

impl<'a> !Send for List<'a>

§

impl<'a> !Sync for List<'a>

§

impl<'a> Unpin for List<'a>

§

impl<'a> UnwindSafe for List<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.