Skip to main content

List

Struct List 

Source
pub struct List { /* private fields */ }
Expand description

A list: a finite sequence, in order.

Implementations§

Source§

impl List

Source

pub fn new() -> Self

Returns the empty list.

Source

pub fn len(&self) -> usize

Returns how many elements there are.

Source

pub fn is_empty(&self) -> bool

Returns whether there are none.

Source

pub fn get(&self, index: usize) -> Option<&Value>

Returns the element at a zero-based position.

Source

pub fn get_int(&self, index: &Int) -> Option<&Value>

Returns the element at a zero-based Int position: None for a negative one or one not less than the length (list.get).

Source

pub fn iter( &self, ) -> impl DoubleEndedIterator<Item = &Value> + ExactSizeIterator

Returns the elements, in order.

Source

pub fn slice(&self, start: usize, end: usize) -> Option<List>

Returns the elements from start up to, not including, end, sharing this list’s buffer, or None unless start ≤ end ≤ length.

Source

pub fn push_back(self, item: Value) -> List

Returns self with item added at the end.

Source

pub fn push_front(self, item: Value) -> List

Returns self with item added at the front.

Source

pub fn concat(self, other: List) -> List

Returns self ++ other.

The elements are added to a buffer nothing else holds: other’s when only it is unshared, or when both are and it is the longer, and otherwise self’s, copied first if it is shared. A list grown one element at a time from either end therefore costs time in what it adds.

Source

pub fn sort_by_keys(&self, keys: &[Value]) -> Result<Option<List>, DataError>

Returns items reordered by keys, one key per item, stably: items whose keys are equal keep their order (list.sort_by).

Returns None when there is not exactly one key per item.

Trait Implementations§

Source§

impl Clone for List

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for List

Source§

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

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

impl Default for List

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for List

Dropping a list nothing else holds hands its nested parts to dismantle in the value module, so a deep value drops without deep recursion.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl FromIterator<Value> for List

Source§

fn from_iter<I: IntoIterator<Item = Value>>(items: I) -> Self

Creates a value from an iterator. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for List

§

impl !UnwindSafe for List

§

impl Freeze for List

§

impl Send for List

§

impl Sync for List

§

impl Unpin for List

§

impl UnsafeUnpin for List

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.