Struct Array
pub struct Array(/* private fields */);Expand description
A sequence of values.
Implementations§
§impl Array
impl Array
pub fn with_capacity(capacity: usize) -> Array
pub fn with_capacity(capacity: usize) -> Array
Creates a new vec, with a known capacity.
pub fn first_mut(&mut self) -> Result<&mut Value, EcoString>
pub fn first_mut(&mut self) -> Result<&mut Value, EcoString>
Mutably borrow the first value in the array.
pub fn last_mut(&mut self) -> Result<&mut Value, EcoString>
pub fn last_mut(&mut self) -> Result<&mut Value, EcoString>
Mutably borrow the last value in the array.
§impl Array
impl Array
pub fn first(&self, default: Option<Value>) -> Result<Value, EcoString>
pub fn first(&self, default: Option<Value>) -> Result<Value, EcoString>
Returns the first item in the array.
pub fn last(&self, default: Option<Value>) -> Result<Value, EcoString>
pub fn last(&self, default: Option<Value>) -> Result<Value, EcoString>
Returns the last item in the array.
pub fn at(&self, index: i64, default: Option<Value>) -> Result<Value, EcoString>
pub fn at(&self, index: i64, default: Option<Value>) -> Result<Value, EcoString>
Returns the item at the specified index in the array.
pub fn pop(&mut self) -> Result<Value, EcoString>
pub fn pop(&mut self) -> Result<Value, EcoString>
Removes the last item from the array and returns it.
pub fn insert(&mut self, index: i64, value: Value) -> Result<(), EcoString>
pub fn insert(&mut self, index: i64, value: Value) -> Result<(), EcoString>
Inserts a value into the array at the specified index, shifting all subsequent elements to the right.
pub fn remove(
&mut self,
index: i64,
default: Option<Value>,
) -> Result<Value, EcoString>
pub fn remove( &mut self, index: i64, default: Option<Value>, ) -> Result<Value, EcoString>
Removes the value at the specified index from the array and return it.
pub fn slice(
&self,
start: i64,
end: Option<i64>,
count: Option<i64>,
) -> Result<Array, EcoString>
pub fn slice( &self, start: i64, end: Option<i64>, count: Option<i64>, ) -> Result<Array, EcoString>
Extracts a subslice of the array.
pub fn find(
&self,
engine: &mut Engine<'_>,
context: Tracked<'_, Context<'_>>,
searcher: Func,
) -> Result<Option<Value>, EcoVec<SourceDiagnostic>>
pub fn find( &self, engine: &mut Engine<'_>, context: Tracked<'_, Context<'_>>, searcher: Func, ) -> Result<Option<Value>, EcoVec<SourceDiagnostic>>
Searches for an item for which the given function returns {true} and returns the first match or {none} if there is no match.
pub fn position(
&self,
engine: &mut Engine<'_>,
context: Tracked<'_, Context<'_>>,
searcher: Func,
) -> Result<Option<i64>, EcoVec<SourceDiagnostic>>
pub fn position( &self, engine: &mut Engine<'_>, context: Tracked<'_, Context<'_>>, searcher: Func, ) -> Result<Option<i64>, EcoVec<SourceDiagnostic>>
Searches for an item for which the given function returns {true} and returns the index of the first match or {none} if there is no match.
pub fn range(
args: &mut Args,
inclusive: bool,
step: NonZero<i64>,
) -> Result<Array, EcoVec<SourceDiagnostic>>
pub fn range( args: &mut Args, inclusive: bool, step: NonZero<i64>, ) -> Result<Array, EcoVec<SourceDiagnostic>>
Create an array consisting of a sequence of numbers.
pub fn filter(
&self,
engine: &mut Engine<'_>,
context: Tracked<'_, Context<'_>>,
test: Func,
) -> Result<Array, EcoVec<SourceDiagnostic>>
pub fn filter( &self, engine: &mut Engine<'_>, context: Tracked<'_, Context<'_>>, test: Func, ) -> Result<Array, EcoVec<SourceDiagnostic>>
Produces a new array with only the items from the original one for which the given function returns {true}.
pub fn map(
self,
engine: &mut Engine<'_>,
context: Tracked<'_, Context<'_>>,
mapper: Func,
) -> Result<Array, EcoVec<SourceDiagnostic>>
pub fn map( self, engine: &mut Engine<'_>, context: Tracked<'_, Context<'_>>, mapper: Func, ) -> Result<Array, EcoVec<SourceDiagnostic>>
Produces a new array in which all items from the original one were transformed with the given function.
pub fn enumerate(self, start: i64) -> Result<Array, EcoString>
pub fn enumerate(self, start: i64) -> Result<Array, EcoString>
Returns a new array with the values alongside their indices.
pub fn zip(
self,
args: &mut Args,
exact: bool,
) -> Result<Array, EcoVec<SourceDiagnostic>>
pub fn zip( self, args: &mut Args, exact: bool, ) -> Result<Array, EcoVec<SourceDiagnostic>>
Zips the array with other arrays.
pub fn fold(
self,
engine: &mut Engine<'_>,
context: Tracked<'_, Context<'_>>,
init: Value,
folder: Func,
) -> Result<Value, EcoVec<SourceDiagnostic>>
pub fn fold( self, engine: &mut Engine<'_>, context: Tracked<'_, Context<'_>>, init: Value, folder: Func, ) -> Result<Value, EcoVec<SourceDiagnostic>>
Folds all items into a single value using an accumulator function.
pub fn sum(self, default: Option<Value>) -> Result<Value, HintedString>
pub fn sum(self, default: Option<Value>) -> Result<Value, HintedString>
Sums all items (works for all types that can be added).
pub fn product(self, default: Option<Value>) -> Result<Value, HintedString>
pub fn product(self, default: Option<Value>) -> Result<Value, HintedString>
Calculates the product of all items (works for all types that can be multiplied).
pub fn any(
self,
engine: &mut Engine<'_>,
context: Tracked<'_, Context<'_>>,
test: Func,
) -> Result<bool, EcoVec<SourceDiagnostic>>
pub fn any( self, engine: &mut Engine<'_>, context: Tracked<'_, Context<'_>>, test: Func, ) -> Result<bool, EcoVec<SourceDiagnostic>>
Whether the given function returns {true} for any item in the array.
pub fn all(
self,
engine: &mut Engine<'_>,
context: Tracked<'_, Context<'_>>,
test: Func,
) -> Result<bool, EcoVec<SourceDiagnostic>>
pub fn all( self, engine: &mut Engine<'_>, context: Tracked<'_, Context<'_>>, test: Func, ) -> Result<bool, EcoVec<SourceDiagnostic>>
Whether the given function returns {true} for all items in the array.
pub fn join(
self,
separator: Option<Value>,
last: Option<Value>,
default: Option<Value>,
) -> Result<Value, EcoString>
pub fn join( self, separator: Option<Value>, last: Option<Value>, default: Option<Value>, ) -> Result<Value, EcoString>
Combine all items in the array into one.
pub fn intersperse(self, separator: Value) -> Array
pub fn intersperse(self, separator: Value) -> Array
Returns an array with a copy of the separator value placed between adjacent elements.
pub fn chunks(self, chunk_size: NonZero<usize>, exact: bool) -> Array
pub fn chunks(self, chunk_size: NonZero<usize>, exact: bool) -> Array
Splits an array into non-overlapping chunks, starting at the beginning, ending with a single remainder chunk.
pub fn windows(self, window_size: NonZero<usize>) -> Array
pub fn windows(self, window_size: NonZero<usize>) -> Array
Returns sliding windows of window-size elements over an array.
pub fn sorted(
self,
engine: &mut Engine<'_>,
context: Tracked<'_, Context<'_>>,
span: Span,
key: Option<Func>,
by: Option<Func>,
) -> Result<Array, EcoVec<SourceDiagnostic>>
pub fn sorted( self, engine: &mut Engine<'_>, context: Tracked<'_, Context<'_>>, span: Span, key: Option<Func>, by: Option<Func>, ) -> Result<Array, EcoVec<SourceDiagnostic>>
Return a sorted version of this array, optionally by a given key function.
Trait Implementations§
§impl<'de> Deserialize<'de> for Array
impl<'de> Deserialize<'de> for Array
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Array, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Array, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Extend<Value> for Array
impl Extend<Value> for Array
§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = Value>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = Value>,
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)§impl FromIterator<Value> for Array
impl FromIterator<Value> for Array
§impl FromValue for Array
impl FromValue for Array
§fn from_value(value: Value) -> Result<Array, HintedString>
fn from_value(value: Value) -> Result<Array, HintedString>
Self.§impl<'a> IntoIterator for &'a Array
impl<'a> IntoIterator for &'a Array
§impl IntoIterator for Array
impl IntoIterator for Array
§impl NativeScope for Array
impl NativeScope for Array
§fn constructor() -> Option<&'static NativeFuncData>
fn constructor() -> Option<&'static NativeFuncData>
§impl NativeType for Array
impl NativeType for Array
§impl Reflect for Array
impl Reflect for Array
§fn error(found: &Value) -> HintedString
fn error(found: &Value) -> HintedString
§impl Serialize for Array
impl Serialize for Array
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CallHasher for T
impl<T> CallHasher for T
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.§impl<T> FromValue<Spanned<Value>> for Twhere
T: FromValue,
impl<T> FromValue<Spanned<Value>> for Twhere
T: FromValue,
§fn from_value(value: Spanned<Value>) -> Result<T, HintedString>
fn from_value(value: Spanned<Value>) -> Result<T, HintedString>
Self.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.§impl<I, T> IntoArgs for Iwhere
I: IntoIterator<Item = T>,
T: IntoValue,
impl<I, T> IntoArgs for Iwhere
I: IntoIterator<Item = T>,
T: IntoValue,
Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoResult for Twhere
T: IntoValue,
impl<T> IntoResult for Twhere
T: IntoValue,
§fn into_result(self, _: Span) -> Result<Value, EcoVec<SourceDiagnostic>>
fn into_result(self, _: Span) -> Result<Value, EcoVec<SourceDiagnostic>>
Source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
§impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
Source§impl<T> StrictAs for T
impl<T> StrictAs for T
Source§fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
Source§impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
Source§fn strict_cast_from(src: Src) -> Dst
fn strict_cast_from(src: Src) -> Dst
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more