Struct arithmetic_eval::Tuple

source ·
pub struct Tuple<T> { /* private fields */ }
Expand description

Tuple of zero or more values.

A tuple is similar to a Vec with Value elements and can be converted from / to it. It is possible to iterate over elements, index them, etc.

§Examples

let mut tuple = Tuple::<u32>::default();
tuple.push(Value::Prim(3));
tuple.push(Value::Prim(5));
assert_eq!(tuple.len(), 2);
assert_eq!(tuple[1], Value::Prim(5));
assert!(tuple.iter().all(|val| !val.is_void()));

// `Tuple` implements `FromIterator` / `Extend`.
let mut other_tuple: Tuple<u32> = (0..=2).map(Value::Prim).collect();
other_tuple.extend(tuple);
assert_eq!(other_tuple.len(), 5);

Implementations§

source§

impl<T> Tuple<T>

source

pub const fn void() -> Self

Creates a new empty tuple (aka a void value).

source

pub fn len(&self) -> usize

Returns the number of elements in this tuple.

source

pub fn is_empty(&self) -> bool

Checks if this tuple is empty (has no elements).

source

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

Iterates over the elements in this tuple.

source

pub fn push(&mut self, value: impl Into<Value<T>>)

Pushes a value to the end of this tuple.

Trait Implementations§

source§

impl<T: Clone> Clone for Tuple<T>

source§

fn clone(&self) -> Tuple<T>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for Tuple<T>

source§

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

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

impl<T> Default for Tuple<T>

source§

fn default() -> Self

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

impl<T: Display> Display for Tuple<T>

source§

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

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

impl<T, V> Extend<V> for Tuple<T>
where V: Into<Value<T>>,

source§

fn extend<I: IntoIterator<Item = V>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<T> From<Tuple<T>> for Value<T>

source§

fn from(tuple: Tuple<T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<Tuple<T>> for Vec<Value<T>>

source§

fn from(tuple: Tuple<T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<Vec<Value<T>>> for Tuple<T>

source§

fn from(elements: Vec<Value<T>>) -> Self

Converts to this type from the input type.
source§

impl<T, V> FromIterator<V> for Tuple<T>
where V: Into<Value<T>>,

source§

fn from_iter<I: IntoIterator<Item = V>>(iter: I) -> Self

Creates a value from an iterator. Read more
source§

impl<T> Index<usize> for Tuple<T>

§

type Output = Value<T>

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<T> IntoEvalResult<T> for Tuple<T>

source§

fn into_eval_result(self) -> Result<Value<T>, ErrorOutput>

Performs the conversion.
source§

impl<'r, T> IntoIterator for &'r Tuple<T>

§

type IntoIter = Iter<'r, Value<T>>

Iterator type should be considered an implementation detail.

§

type Item = &'r Value<T>

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T> IntoIterator for Tuple<T>

§

type IntoIter = IntoIter<Value<T>>

Iterator type should be considered an implementation detail.

§

type Item = Value<T>

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T: PartialEq> PartialEq for Tuple<T>

source§

fn eq(&self, other: &Tuple<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> TryFromValue<T> for Tuple<T>

source§

fn try_from_value(value: Value<T>) -> Result<Self, FromValueError>

Attempts to convert value to a type supported by the function.
source§

impl<T> StructuralPartialEq for Tuple<T>

Auto Trait Implementations§

§

impl<T> Freeze for Tuple<T>

§

impl<T> !RefUnwindSafe for Tuple<T>

§

impl<T> !Send for Tuple<T>

§

impl<T> !Sync for Tuple<T>

§

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

§

impl<T> !UnwindSafe for Tuple<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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.