Skip to main content

Motion

Struct Motion 

Source
pub struct Motion<Description = DurationDescription> { /* private fields */ }
Expand description

A deterministic, time-sampled motion from a start value to a target.

Motion describes how a value moves over time, and it doesn’t hold the value. It is either duration-based (the default) or spring-based, depending on Description. Call Motion::sample with the time since the run started to get the progress and the lifecycle state at that moment.

A duration motion has one forward MotionPass, an optional reverse pass, an initial delay, and a Playback policy. The default is one forward iteration with no delay. The delay applies once, when a run begins.

Motion::iterations counts total iterations, including the first. Restarting motion begins each iteration with local time at zero. Motion::alternate starts forward, then uses a backward leg on every second iteration. Direction::AlternateReverse starts backward instead. With conventional easing endpoints, forward-first alternating motion rests at its target after an odd count and at its origin after an even count. Reverse-first alternating motion has the opposite endpoints. Custom easing endpoints may settle elsewhere, including outside zero through one.

A backward leg uses the configured reverse pass, or reuses the forward pass’s duration and easing if no reverse pass is configured. Reverse local time still advances from zero to one and is eased in that direction. The resulting presentation progress is 1 - eased. For example, reverse ease-in starts the backward leg slowly and accelerates toward the origin.

Local pass time is normalized. Eased presentation may overshoot, as in upstream spring easing, while pass selection remains deterministic. Finite zero-duration motion resolves immediately once its initial delay is satisfied, with the configured direction and iteration parity determining the final presentation. A zero-length leg in otherwise nonzero alternating motion is instantaneous. Indefinite motion whose applicable passes all have zero duration becomes inactive instead of requesting animation frames forever.

§Examples

Ease a one-pass motion. At a quarter of the way through, ease_in_out gives 0.125.

use gpui::{Motion, ease_in_out, millis};

let motion = Motion::new(millis(200)).with_easing(ease_in_out);
assert_eq!(motion.sample(millis(50)).progress.get(), 0.125);
assert!(motion.sample(millis(200)).is_at_end());

Restart the pass three times. Each iteration begins again from zero.

use gpui::{Motion, millis};

let motion = Motion::new(millis(1000)).iterations(3);
let sample = motion.sample(millis(2500));
assert_eq!(sample.iteration, 2);
assert_eq!(sample.local_time.get(), 0.5);
assert!(motion.sample(millis(3000)).is_complete());

Alternate the direction. After an even number of iterations the motion rests at its origin.

use gpui::{Motion, Progress, millis};

let motion = Motion::new(millis(1000)).iterations(2).alternate();
assert_eq!(motion.sample(millis(1500)).progress.get(), 0.5);
assert_eq!(motion.sample(millis(2000)).progress, Progress::START);

Implementations§

Source§

impl Motion<DurationDescription>

Source

pub fn new(duration: Duration) -> Self

Creates a one-pass linear motion of duration, with no delay, run once.

Source

pub fn with_easing(self, easing: impl Fn(f32) -> f32 + 'static) -> Self

Sets the easing of the forward pass.

An alternating motion without an explicit reverse pass uses this easing for its backward legs too.

Source

pub fn with_spring(self, config: SpringConfig) -> Self

Replaces the easing with a spring sampled over this motion’s duration.

The spring starts at rest and reaches its target at the end of the duration. It doesn’t settle on its own and it doesn’t keep velocity across retargets. For a spring that settles and keeps its velocity, use Motion::spring.

Source

pub fn with_forward_pass(self, pass: MotionPass) -> Self

Replaces the forward pass, including its duration and easing.

Source

pub fn with_reverse_pass(self, pass: MotionPass) -> Self

Sets the pass used for backward legs.

This doesn’t infer direction from changes to an Animated target. A newly retargeted run begins with its configured direction. Without an explicit reverse pass, backward legs reuse the forward pass’s duration and easing.

Reverse local time advances from zero to one and is eased normally. Its presentation is then mapped as 1 - eased, so a reverse ease-in begins slowly and accelerates toward the origin.

Source

pub fn with_delay(self, delay: Duration) -> Self

Delays the start of the run by delay.

The delay applies once, before the first iteration. Restarted iterations don’t wait again. During the delay, the progress is the start value of the run.

Source

pub fn iterations(self, iterations: u32) -> Self

Sets the total number of iterations, including the first.

The default is one. Each iteration restarts local timing. In forward-first alternating motion, odd-numbered iterations are forward and even-numbered iterations are backward. With conventional easing endpoints, counts of one and three rest at the target, and counts of two and four rest at the origin.

§Panics

Panics if iterations is zero.

Source

pub fn repeat_forever(self) -> Self

Repeats this motion without end.

Each iteration restarts from the start unless the motion alternates. A motion whose applicable passes all have zero duration becomes MotionPhase::Inactive, resting at a deterministic presentation.

Source

pub fn alternate(self) -> Self

Alternates the direction of successive iterations.

Odd-numbered iterations use the forward pass. Even-numbered iterations use the reverse pass, or the forward pass when none is configured. This is the same as direction(Direction::Alternate).

Source

pub fn direction(self, direction: Direction) -> Self

Sets the direction of successive iterations.

Source

pub fn with_playback(self, playback: Playback) -> Self

Replaces the whole playback policy: iterations and direction.

Source

pub fn forward_pass(&self) -> &MotionPass

Returns the forward pass.

Source

pub fn reverse_pass(&self) -> Option<&MotionPass>

Returns the reverse pass, or None when backward legs reuse the forward pass.

Source

pub fn delay(&self) -> Duration

Returns the delay applied before the first iteration.

Source

pub const fn playback(&self) -> Playback

Returns the iteration count and direction of this motion.

Source

pub fn checked_extent(&self) -> Option<MotionExtent>

Returns the total length of the run, including the delay.

Returns MotionExtent::Infinite for Motion::repeat_forever. Returns None only when a finite total is too large for Duration.

§Examples
use gpui::{Motion, MotionExtent, millis};

let motion = Motion::new(millis(300)).with_delay(millis(200)).iterations(3);
assert_eq!(motion.checked_extent(), Some(MotionExtent::Finite(millis(1100))));
Source

pub fn sample(&self, elapsed: Duration) -> MotionSample

Samples this motion at elapsed, measured from the start of the run.

Before the delay ends, the phase is MotionPhase::Delayed. After the last iteration of a finite run, it is MotionPhase::Completed at the final progress. Pass selection, iteration parity and completion use integer nanosecond arithmetic. Only the fraction within the selected pass is converted to a float for easing.

Source

pub fn sample_at<Time>(&self, started_at: Time, now: Time) -> MotionSample
where Time: Sub<Time, Output = Duration>,

Samples this motion at now, given the time started_at when the run began.

Time can be any type that subtracts to a Duration, such as std::time::Instant or the executor’s clock.

Source§

impl Motion<SpringDescription>

Source

pub fn spring(config: SpringConfig) -> Self

Creates a spring that runs until it settles.

Give the spring a target with Motion::to. The settling tolerance defaults to 0.001. Change it with Motion::with_epsilon.

Source

pub fn config(&self) -> SpringConfig

Returns the physical parameters of this spring.

Source

pub fn epsilon(&self) -> f32

Returns the settling tolerance of this spring.

Source

pub fn with_epsilon(self, epsilon: f32) -> Self

Sets how close the spring must be to its target before it counts as settled.

The tolerance applies to position, and to velocity scaled by the spring’s natural frequency. Changing it also recomputes the settling time, which is when Motion::sample reports MotionPhase::Completed.

Source

pub fn sample(&self, elapsed: Duration) -> MotionSample

Samples this spring at elapsed, starting from rest at zero progress.

Progress is the spring’s position, which overshoots when the spring is underdamped. From the settling time onward the sample is MotionPhase::Completed at Progress::END, and it is no longer active.

§Examples
use gpui::{Motion, Progress, millis, secs, spring};

let motion = Motion::spring(spring(100., 10., 1.));
assert!(motion.sample(millis(0)).is_active);
let settled = motion.sample(secs(10));
assert!(settled.is_complete());
assert_eq!(settled.progress, Progress::END);
Source

pub fn to<T: SpringTarget>(self, target: T) -> SpringAnimation<T>

Targets target with this spring.

The result is a SpringAnimation for AnimationExt::with_spring.

Trait Implementations§

Source§

impl<Description: Clone> Clone for Motion<Description>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<Description: Debug> Debug for Motion<Description>

Source§

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

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

impl Default for Motion<DurationDescription>

Source§

fn default() -> Self

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

impl<Description> Deref for Motion<Description>

Source§

type Target = Description

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl<Description> DerefMut for Motion<Description>

Source§

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

Mutably dereferences the value.
Source§

impl From<&Motion<SpringDescription>> for AnyMotion

Source§

fn from(motion: &Motion<SpringDescription>) -> Self

Converts to this type from the input type.
Source§

impl From<&Motion> for AnyMotion

Source§

fn from(motion: &Motion<DurationDescription>) -> Self

Converts to this type from the input type.
Source§

impl From<Duration> for Motion<DurationDescription>

Source§

fn from(duration: Duration) -> Self

Converts to this type from the input type.
Source§

impl From<Motion<SpringDescription>> for AnyMotion

Source§

fn from(motion: Motion<SpringDescription>) -> Self

Converts to this type from the input type.
Source§

impl From<Motion> for AnyMotion

Source§

fn from(motion: Motion<DurationDescription>) -> Self

Converts to this type from the input type.
Source§

impl From<SpringConfig> for Motion<SpringDescription>

Source§

fn from(config: SpringConfig) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<Description> Freeze for Motion<Description>
where Description: Freeze,

§

impl<Description> RefUnwindSafe for Motion<Description>
where Description: RefUnwindSafe,

§

impl<Description> Send for Motion<Description>
where Description: Send,

§

impl<Description> Sync for Motion<Description>
where Description: Sync,

§

impl<Description> Unpin for Motion<Description>
where Description: Unpin,

§

impl<Description> UnsafeUnpin for Motion<Description>
where Description: UnsafeUnpin,

§

impl<Description> UnwindSafe for Motion<Description>
where Description: UnwindSafe,

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where 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) -> D
where M: TransformMatrix<T>,

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the bradford method by default.
Source§

impl<T, C> AdaptIntoUnclamped<T> for C
where T: AdaptFromUnclamped<C>,

Source§

type Scalar = <T as AdaptFromUnclamped<C>>::Scalar

The number type that’s used as the color’s components.
Source§

fn adapt_into_unclamped_with<M>(self) -> T

Adapt a color of type Self into a color of type T, using the custom matrix M. Read more
Source§

fn adapt_into_unclamped(self) -> T
where Bradford: LmsToXyz<Self::Scalar> + XyzToLms<Self::Scalar>,

Adapt a color of type Self into a color of type T, using the Bradford matrix. Read more
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, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
Source§

impl<T, C> ComponentsInto<C> for T

Source§

fn components_into(self) -> C

Cast this collection of color components into a collection of colors. Read more
Source§

impl<T> CryptoRng for T
where T: DerefMut, <T as Deref>::Target: CryptoRng,

Source§

impl<R> CryptoRng for R
where R: TryCryptoRng<Error = !> + ?Sized,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<R> Rng for R
where R: RngCore + ?Sized,

Source§

fn random<T>(&mut self) -> T

Return a random value via the StandardUniform distribution. Read more
Source§

fn random_iter<T>(self) -> Iter<StandardUniform, Self, T> ⓘ

Return an iterator over random variates Read more
Source§

fn random_range<T, R>(&mut self, range: R) -> T
where T: SampleUniform, R: SampleRange<T>,

Generate a random value in the given range. Read more
Source§

fn random_bool(&mut self, p: f64) -> bool

Return a bool with a probability p of being true. Read more
Source§

fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool

Return a bool with a probability of numerator/denominator of being true. Read more
Source§

fn sample<T, D>(&mut self, distr: D) -> T
where D: Distribution<T>,

Sample a new value, using the given distribution. Read more
Source§

fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T> ⓘ
where D: Distribution<T>, Self: Sized,

Create an iterator that generates values using the given distribution. Read more
Source§

fn fill<T>(&mut self, dest: &mut T)
where T: Fill + ?Sized,

Fill any type implementing Fill with random data Read more
Source§

fn gen<T>(&mut self) -> T

👎Deprecated since 0.9.0:

Renamed to random to avoid conflict with the new gen keyword in Rust 2024.

Alias for Rng::random.
Source§

fn gen_range<T, R>(&mut self, range: R) -> T
where T: SampleUniform, R: SampleRange<T>,

👎Deprecated since 0.9.0:

Renamed to random_range

Source§

fn gen_bool(&mut self, p: f64) -> bool

👎Deprecated since 0.9.0:

Renamed to random_bool

Alias for Rng::random_bool.
Source§

fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool

👎Deprecated since 0.9.0:

Renamed to random_ratio

Source§

impl<R> Rng for R
where R: TryRng<Error = !> + ?Sized,

Source§

fn next_u32(&mut self) -> u32

Return the next random u32.
Source§

fn next_u64(&mut self) -> u64

Return the next random u64.
Source§

fn fill_bytes(&mut self, dst: &mut [u8])

Fill dest with random data. Read more
Source§

impl<T> RngCore for T
where T: DerefMut, <T as Deref>::Target: RngCore,

Source§

fn next_u32(&mut self) -> u32

Return the next random u32. Read more
Source§

fn next_u64(&mut self) -> u64

Return the next random u64. Read more
Source§

fn fill_bytes(&mut self, dst: &mut [u8])

Fill dest with random data. Read more
Source§

impl<R> RngCore for R
where R: Rng,

Source§

impl<R> RngExt for R
where R: Rng + ?Sized,

Source§

fn random<T>(&mut self) -> T

Return a random value via the StandardUniform distribution. Read more
Source§

fn random_iter<T>(self) -> Iter<StandardUniform, Self, T> ⓘ

Return an iterator over random variates Read more
Source§

fn random_range<T, R>(&mut self, range: R) -> T
where T: SampleUniform, R: SampleRange<T>,

Generate a random value in the given range. Read more
Source§

fn random_bool(&mut self, p: f64) -> bool

Return a bool with a probability p of being true. Read more
Source§

fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool

Return a bool with a probability of numerator/denominator of being true. Read more
Source§

fn sample<T, D>(&mut self, distr: D) -> T
where D: Distribution<T>,

Sample a new value, using the given distribution. Read more
Source§

fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T> ⓘ
where D: Distribution<T>, Self: Sized,

Create an iterator that generates values using the given distribution. Read more
Source§

fn fill<T>(&mut self, dest: &mut [T])
where T: Fill,

Fill any type implementing Fill with random data Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. Read more
Source§

impl<R> TryCryptoRng for R
where R: CryptoRng + ?Sized,

Source§

impl<R> TryCryptoRng for R
where R: DerefMut, <R as Deref>::Target: TryCryptoRng,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<R> TryRng for R
where R: DerefMut, <R as Deref>::Target: TryRng,

Source§

type Error = <<R as Deref>::Target as TryRng>::Error

The type returned in the event of a RNG error. Read more
Source§

fn try_next_u32(&mut self) -> Result<u32, <R as TryRng>::Error>

Return the next random u32.
Source§

fn try_next_u64(&mut self) -> Result<u64, <R as TryRng>::Error>

Return the next random u64.
Source§

fn try_fill_bytes(&mut self, dst: &mut [u8]) -> Result<(), <R as TryRng>::Error>

Fill dst entirely with random data.
Source§

impl<R> TryRngCore for R
where R: RngCore + ?Sized,

Source§

type Error = !

The type returned in the event of a RNG error.
Source§

fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>

Return the next random u32.
Source§

fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>

Return the next random u64.
Source§

fn try_fill_bytes( &mut self, dst: &mut [u8], ) -> Result<(), <R as TryRngCore>::Error>

Fill dest entirely with random data.
Source§

fn unwrap_err(self) -> UnwrapErr<Self>
where Self: Sized,

Wrap RNG with the UnwrapErr wrapper.
Source§

fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>

Wrap RNG with the UnwrapMut wrapper.
Source§

fn read_adapter(&mut self) -> RngReadAdapter<'_, Self> ⓘ
where Self: Sized,

Convert an RngCore to a RngReadAdapter.
Source§

impl<R> TryRngCore for R
where R: TryRng,

Source§

type Error = <R as TryRng>::Error

👎Deprecated since 0.10.0:

use TryRng instead

Error type.
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more