Struct Seq

Source
pub struct Seq<T>(/* private fields */);
Expand description

A lazily evaluated sequence of functions.

Implementations§

Source§

impl<T> Seq<T>

Source

pub fn new() -> Seq<T>

Constructs a new, empty Seq<T>.

Source

pub fn is_empty(&self) -> bool

Returns true if the sequence contains no elements.

Source

pub fn capacity(&self) -> usize

Source

pub fn len(&self) -> usize

Returns the number of elements in the sequence, also referred to as its ‘length’.

Source

pub fn with_capacity(capacity: usize) -> Seq<T>

Constructs a new, empty Seq<T> with the specified capacity.

Source

pub fn push<F: FnOnce() -> T + 'static>(&mut self, value: F)

Appends the provided function to the back of the collection.

Source

pub fn pop(&mut self) -> Option<T>

Forces evaluation of the last function in the sequence, returning the result.

Source

pub fn force_all(&mut self)

Evaluates all unevaluated functions within the Seq.

Source

pub fn to_vec(self) -> Vec<T>

Converts a Seq<T> to a Vec<T> by forcing evaluation of all functions.

Source

pub fn to_lazy_vec(self) -> Vec<Lazy<T>>

Converts a Seq<T> to a Vec<Lazy<T>> without evaluating any additional functions.

Source

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

Gets an immutable reference to the value at the specified index.

Source

pub fn get_mut(&mut self, index: usize) -> Option<&mut T>

Gets a mutable reference to the value at the specified index.

Trait Implementations§

Source§

impl<T> Default for Seq<T>

Source§

fn default() -> Self

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

impl<T> From<Vec<Box<dyn FnOnce() -> T>>> for Seq<T>

Source§

fn from(vec: Vec<Box<dyn FnOnce() -> T>>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Vec<T>> for Seq<T>

Source§

fn from(vec: Vec<T>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> Freeze for Seq<T>

§

impl<T> !RefUnwindSafe for Seq<T>

§

impl<T> !Send for Seq<T>

§

impl<T> !Sync for Seq<T>

§

impl<T> Unpin for Seq<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Seq<T>

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.