pub struct Array(/* private fields */);Expand description
A sequence of values.
Implementations§
Source§impl Array
impl Array
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new vec, with a known capacity.
Sourcepub fn first_mut(&mut self) -> StrResult<&mut Value>
pub fn first_mut(&mut self) -> StrResult<&mut Value>
Mutably borrow the first value in the array.
Sourcepub fn last_mut(&mut self) -> StrResult<&mut Value>
pub fn last_mut(&mut self) -> StrResult<&mut Value>
Mutably borrow the last value in the array.
Source§impl Array
impl Array
Sourcepub fn first(&self, default: Option<Value>) -> StrResult<Value>
pub fn first(&self, default: Option<Value>) -> StrResult<Value>
Returns the first item in the array.
Sourcepub fn last(&self, default: Option<Value>) -> StrResult<Value>
pub fn last(&self, default: Option<Value>) -> StrResult<Value>
Returns the last item in the array.
Sourcepub fn at(&self, index: i64, default: Option<Value>) -> StrResult<Value>
pub fn at(&self, index: i64, default: Option<Value>) -> StrResult<Value>
Returns the item at the specified index in the array.
Sourcepub fn insert(&mut self, index: i64, value: Value) -> StrResult<()>
pub fn insert(&mut self, index: i64, value: Value) -> StrResult<()>
Inserts a value into the array at the specified index, shifting all subsequent elements to the right.
Sourcepub fn remove(&mut self, index: i64, default: Option<Value>) -> StrResult<Value>
pub fn remove(&mut self, index: i64, default: Option<Value>) -> StrResult<Value>
Removes the value at the specified index from the array and return it.
Sourcepub fn slice(
&self,
start: i64,
end: Option<i64>,
count: Option<i64>,
) -> StrResult<Array>
pub fn slice( &self, start: i64, end: Option<i64>, count: Option<i64>, ) -> StrResult<Array>
Extracts a subslice of the array.
Sourcepub fn find(
&self,
engine: &mut Engine<'_>,
context: Tracked<'_, Context<'_>>,
searcher: Func,
) -> SourceResult<Option<Value>>
pub fn find( &self, engine: &mut Engine<'_>, context: Tracked<'_, Context<'_>>, searcher: Func, ) -> SourceResult<Option<Value>>
Searches for an item for which the given function returns {true} and returns the first match or {none} if there is no match.
Sourcepub fn position(
&self,
engine: &mut Engine<'_>,
context: Tracked<'_, Context<'_>>,
searcher: Func,
) -> SourceResult<Option<i64>>
pub fn position( &self, engine: &mut Engine<'_>, context: Tracked<'_, Context<'_>>, searcher: Func, ) -> SourceResult<Option<i64>>
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.
Sourcepub fn range(
args: &mut Args,
inclusive: bool,
step: NonZeroI64,
) -> SourceResult<Array>
pub fn range( args: &mut Args, inclusive: bool, step: NonZeroI64, ) -> SourceResult<Array>
Create an array consisting of a sequence of numbers.
Sourcepub fn filter(
&self,
engine: &mut Engine<'_>,
context: Tracked<'_, Context<'_>>,
test: Func,
) -> SourceResult<Array>
pub fn filter( &self, engine: &mut Engine<'_>, context: Tracked<'_, Context<'_>>, test: Func, ) -> SourceResult<Array>
Produces a new array with only the items from the original one for which the given function returns {true}.
Sourcepub fn map(
self,
engine: &mut Engine<'_>,
context: Tracked<'_, Context<'_>>,
mapper: Func,
) -> SourceResult<Array>
pub fn map( self, engine: &mut Engine<'_>, context: Tracked<'_, Context<'_>>, mapper: Func, ) -> SourceResult<Array>
Produces a new array in which all items from the original one were transformed with the given function.
Sourcepub fn enumerate(self, start: i64) -> StrResult<Array>
pub fn enumerate(self, start: i64) -> StrResult<Array>
Returns a new array with the values alongside their indices.
Sourcepub fn zip(self, args: &mut Args, exact: bool) -> SourceResult<Array>
pub fn zip(self, args: &mut Args, exact: bool) -> SourceResult<Array>
Zips the array with other arrays.
Sourcepub fn fold(
self,
engine: &mut Engine<'_>,
context: Tracked<'_, Context<'_>>,
init: Value,
folder: Func,
) -> SourceResult<Value>
pub fn fold( self, engine: &mut Engine<'_>, context: Tracked<'_, Context<'_>>, init: Value, folder: Func, ) -> SourceResult<Value>
Folds all items into a single value using an accumulator function.
Sourcepub fn sum(self, default: Option<Value>) -> HintedStrResult<Value>
pub fn sum(self, default: Option<Value>) -> HintedStrResult<Value>
Sums all items (works for all types that can be added).
Sourcepub fn product(self, default: Option<Value>) -> HintedStrResult<Value>
pub fn product(self, default: Option<Value>) -> HintedStrResult<Value>
Calculates the product of all items (works for all types that can be multiplied).
Sourcepub fn any(
self,
engine: &mut Engine<'_>,
context: Tracked<'_, Context<'_>>,
test: Func,
) -> SourceResult<bool>
pub fn any( self, engine: &mut Engine<'_>, context: Tracked<'_, Context<'_>>, test: Func, ) -> SourceResult<bool>
Whether the given function returns {true} for any item in the array.
Sourcepub fn all(
self,
engine: &mut Engine<'_>,
context: Tracked<'_, Context<'_>>,
test: Func,
) -> SourceResult<bool>
pub fn all( self, engine: &mut Engine<'_>, context: Tracked<'_, Context<'_>>, test: Func, ) -> SourceResult<bool>
Whether the given function returns {true} for all items in the array.
Sourcepub fn join(
self,
separator: Option<Value>,
last: Option<Value>,
default: Option<Value>,
) -> StrResult<Value>
pub fn join( self, separator: Option<Value>, last: Option<Value>, default: Option<Value>, ) -> StrResult<Value>
Combine all items in the array into one.
Sourcepub 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.
Sourcepub fn chunks(self, chunk_size: NonZeroUsize, exact: bool) -> Array
pub fn chunks(self, chunk_size: NonZeroUsize, exact: bool) -> Array
Splits an array into non-overlapping chunks, starting at the beginning, ending with a single remainder chunk.
Sourcepub fn windows(self, window_size: NonZeroUsize) -> Array
pub fn windows(self, window_size: NonZeroUsize) -> Array
Returns sliding windows of window-size elements over an array.
Sourcepub fn sorted(
self,
engine: &mut Engine<'_>,
context: Tracked<'_, Context<'_>>,
span: Span,
key: Option<Func>,
by: Option<Func>,
) -> SourceResult<Array>
pub fn sorted( self, engine: &mut Engine<'_>, context: Tracked<'_, Context<'_>>, span: Span, key: Option<Func>, by: Option<Func>, ) -> SourceResult<Array>
Return a sorted version of this array, optionally by a given key function.
Trait Implementations§
Source§impl AddAssign for Array
impl AddAssign for Array
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl<'de> Deserialize<'de> for Array
impl<'de> Deserialize<'de> for Array
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Extend<Value> for Array
impl Extend<Value> for Array
Source§fn extend<T: IntoIterator<Item = Value>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Value>>(&mut self, iter: T)
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)Source§impl FromIterator<Value> for Array
impl FromIterator<Value> for Array
Source§impl FromValue for Array
impl FromValue for Array
Source§fn from_value(value: Value) -> HintedStrResult<Self>
fn from_value(value: Value) -> HintedStrResult<Self>
Self.Source§impl IntoIterator for Array
impl IntoIterator for Array
Source§impl<'a> IntoIterator for &'a Array
impl<'a> IntoIterator for &'a Array
Source§impl NativeScope for Array
impl NativeScope for Array
Source§fn constructor() -> Option<&'static NativeFuncData>
fn constructor() -> Option<&'static NativeFuncData>
Source§impl NativeType for Array
impl NativeType for Array
impl StructuralPartialEq for Array
Auto Trait Implementations§
impl !RefUnwindSafe for Array
impl !UnwindSafe for Array
impl Freeze for Array
impl Send for Array
impl Sync for Array
impl Unpin for Array
impl UnsafeUnpin 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
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
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<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
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.Source§impl<T> FromValue<Spanned<Value>> for Twhere
T: FromValue,
impl<T> FromValue<Spanned<Value>> for Twhere
T: FromValue,
Source§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.Source§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 moreSource§impl<T> IntoResult for Twhere
T: IntoValue,
impl<T> IntoResult for Twhere
T: IntoValue,
Source§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.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)
Source§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
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