Struct polyvalue::types::Array

source ·
pub struct Array(/* private fields */);
Expand description

Subtype of Value that represents an array

Implementations§

source§

impl Array

source

pub const MAX_CONVERTIBLE_RANGE: usize = 65_536usize

Largest range that can be converted to an array

source

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

Pop a value from the array

source

pub fn push(&mut self, value: Value)

Push a value onto the array

source

pub fn insert(&mut self, index: usize, value: Value)

Insert a value into the array

source

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

Remove a value from the array

source

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

Get a value from the array, if it exists

source

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

Get a mutable value from the array, if it exists

source

pub fn len(&self) -> usize

Get the length of the array

source

pub fn is_empty(&self) -> bool

Determine if the array contains any values

source

pub fn prealloc_range_conversion(length: usize) -> Result<Self, Error>

Preallocate space for a large array conversion

Trait Implementations§

source§

impl Add for Array

§

type Output = Result<Array, Error>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl ArithmeticOperationExt for Array

source§

fn arithmetic_op( self, right: Self, operation: ArithmeticOperation ) -> Result<Self, Error>

Perform an arithmetic operation on two values If the operation is not supported on the given type, an Error::UnsupportedOperation will be returned Read more
source§

fn arithmetic_neg(self) -> Result<Self, Error>
where Self: Sized,

Perform an arithmetic negation on a value This is equivalent to arithmetic_op with ArithmeticOperation::Negate but is provided for convenience Read more
source§

impl BooleanOperationExt for Array

source§

fn boolean_op( self, right: Self, operation: BooleanOperation ) -> Result<Value, Error>

Perform a boolean operation on two values If the operation is not supported on the given type, an Error::UnsupportedOperation will be returned Read more
source§

fn boolean_not(self) -> Result<Value, Error>
where Self: Sized,

Perform a boolean not on a value This is equivalent to boolean_op with BooleanOperation::Not but is provided for convenience Read more
source§

impl Clone for Array

source§

fn clone(&self) -> Array

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 Debug for Array

source§

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

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

impl Default for Array

source§

fn default() -> Array

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

impl DerefMut for Array

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<'de> Deserialize<'de> for Array

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Array

source§

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

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

impl From<Array> for Value

source§

fn from(v: Array) -> Self

Converts to this type from the input type.
source§

impl<V> From<Vec<V>> for Array
where Value: From<V>,

source§

fn from(v: Vec<V>) -> Self

Converts to this type from the input type.
source§

impl Hash for Array

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl IndexingMutationExt for Array

source§

fn get_index_mut(&mut self, index: &Value) -> Result<&mut Value, Error>

Get a value from an index Returns a mutable reference to the value, or an Error::Index if the index is not found Read more
source§

fn get_indices_mut(&mut self, index: &Value) -> Result<Vec<&mut Value>, Error>

Get values from one or more indices, mutably Returns a vector of references to the values, or an Error::Index if any of the indices are not found Read more
source§

fn set_index(&mut self, index: &Value, value: Value) -> Result<(), Error>

Set a value at an index Returns an Error::Index if the index is not found Read more
source§

fn insert_at(&mut self, index: &Value, value: Value) -> Result<(), Error>

Insert a value at an index Returns an Error::Index if the index is out of bounds Read more
source§

fn delete_index(&mut self, index: &Value) -> Result<Value, Error>

Delete a value at an index Returns an Error::Index if the index is not found Read more
source§

impl IndexingOperationExt for Array

source§

fn get_index(&self, index: &Value) -> Result<Value, Error>

Get a value from an index Returns a value, or an Error::Index if the index is not found Read more
source§

fn get_indices(&self, index: &Value) -> Result<Value, Error>

Get values from one or more indices Returns a vector of values, or an Error::Index if any of the indices are not found Read more
source§

impl Into<Vec<Value>> for Array

source§

fn into(self) -> ArrayInner

Converts this type into the (usually inferred) input type.
source§

impl MatchingOperationExt for Array

source§

fn matching_op( container: &Self, pattern: &Value, operation: MatchingOperation ) -> Result<Value, Error>
where Self: Sized,

Perform a matching operation on two values If the operation is not supported on the given type, an Error::UnsupportedOperation will be returned Read more
source§

impl Neg for Array

§

type Output = Result<Array, Error>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl Ord for Array

source§

fn cmp(&self, other: &Array) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Array

source§

fn eq(&self, other: &Array) -> 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 PartialOrd for Array

source§

fn partial_cmp(&self, other: &Array) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for Array

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Sub for Array

§

type Output = Result<Array, Error>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
source§

impl TryFrom<Array> for Bool

§

type Error = Error

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

fn try_from(value: Array) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Array> for Currency

§

type Error = Error

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

fn try_from(value: Array) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Array> for Fixed

§

type Error = Error

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

fn try_from(value: Array) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Array> for Float

§

type Error = Error

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

fn try_from(value: Array) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Array> for I16

§

type Error = Error

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

fn try_from(value: Array) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Array> for I32

§

type Error = Error

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

fn try_from(value: Array) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Array> for I64

§

type Error = Error

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

fn try_from(value: Array) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Array> for I8

§

type Error = Error

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

fn try_from(value: Array) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Array> for Object

§

type Error = Error

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

fn try_from(value: Array) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Array> for Range

§

type Error = Error

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

fn try_from(value: Array) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Array> for Str

§

type Error = Error

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

fn try_from(value: Array) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Array> for U16

§

type Error = Error

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

fn try_from(value: Array) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Array> for U32

§

type Error = Error

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

fn try_from(value: Array) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Array> for U64

§

type Error = Error

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

fn try_from(value: Array) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Array> for U8

§

type Error = Error

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

fn try_from(value: Array) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Bool> for Array

§

type Error = Error

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

fn try_from(value: Bool) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Currency> for Array

§

type Error = Error

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

fn try_from(value: Currency) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Fixed> for Array

§

type Error = Error

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

fn try_from(value: Fixed) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Float> for Array

§

type Error = Error

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

fn try_from(value: Float) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<I16> for Array

§

type Error = Error

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

fn try_from(value: I16) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<I32> for Array

§

type Error = Error

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

fn try_from(value: I32) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<I64> for Array

§

type Error = Error

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

fn try_from(value: I64) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<I8> for Array

§

type Error = Error

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

fn try_from(value: I8) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Object> for Array

§

type Error = Error

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

fn try_from(value: Object) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Range> for Array

§

type Error = Error

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

fn try_from(value: Range) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Str> for Array

§

type Error = Error

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

fn try_from(value: Str) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<U16> for Array

§

type Error = Error

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

fn try_from(value: U16) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<U32> for Array

§

type Error = Error

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

fn try_from(value: U32) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<U64> for Array

§

type Error = Error

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

fn try_from(value: U64) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<U8> for Array

§

type Error = Error

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

fn try_from(value: U8) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for Array

§

type Error = Error

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl ValueTrait for Array

§

type Inner = Vec<Value>

The inner type of the value
source§

fn new(inner: ArrayInner) -> Self

Creates a new value from the given inner value
source§

fn inner(&self) -> &ArrayInner

Returns a reference to the inner value
source§

fn inner_mut(&mut self) -> &mut ArrayInner

Returns a mutable reference to the inner value
source§

fn into_inner(self) -> ArrayInner

Consumes the value and returns the inner value
source§

impl Deref for Array

§

type Target = <Array as ValueTrait>::Inner

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl Eq for Array

source§

impl StructuralPartialEq for Array

Auto Trait Implementations§

§

impl Freeze for Array

§

impl RefUnwindSafe for Array

§

impl Send for Array

§

impl Sync for Array

§

impl Unpin for Array

§

impl UnwindSafe for Array

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> 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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,