MovingPtr

Struct MovingPtr 

Source
pub struct MovingPtr<'a, T, A = Aligned>(/* private fields */)
where
    A: IsAligned;
Expand description

A Box-like pointer for moving a value to a new memory location without needing to pass by value.

Conceptually represents ownership of whatever data is being pointed to and will call its Drop impl upon being dropped. This pointer is not responsible for freeing the memory pointed to by this pointer as it may be pointing to an element in a Vec or to a local in a function etc.

This type tries to act “borrow-like” which means that:

  • Pointer should be considered exclusive and mutable. It cannot be cloned as this would lead to aliased mutability and potentially use after free bugs.
  • It must always point to a valid value of whatever the pointee type is.
  • The lifetime 'a accurately represents how long the pointer is valid for.
  • It does not support pointer arithmetic in any way.
  • If A is Aligned, the pointer must always be properly aligned for the type T.

A value can be deconstructed into its fields via deconstruct_moving_ptr, see it’s documentation for an example on how to use it.

Implementations§

Source§

impl<'a, T> MovingPtr<'a, T>

Source

pub fn to_unaligned(self) -> MovingPtr<'a, T, Unaligned>

Removes the alignment requirement of this pointer

Source

pub unsafe fn from_value(value: &'a mut MaybeUninit<T>) -> MovingPtr<'a, T>

Creates a MovingPtr from a provided value of type T.

For a safer alternative, it is strongly advised to use move_as_ptr where possible.

§Safety
  • value must store a properly initialized value of type T.
  • Once the returned MovingPtr has been used, value must be treated as it were uninitialized unless it was explicitly leaked via core::mem::forget.
Source§

impl<'a, T, A> MovingPtr<'a, T, A>
where A: IsAligned,

Source

pub unsafe fn new(inner: NonNull<T>) -> MovingPtr<'a, T, A>

Creates a new instance from a raw pointer.

For a safer alternative, it is strongly advised to use move_as_ptr where possible.

§Safety
  • inner must point to valid value of T.
  • If the A type parameter is Aligned then inner must be be properly aligned for T.
  • inner must have correct provenance to allow read and writes of the pointee type.
  • The lifetime 'a must be constrained such that this MovingPtr will stay valid and nothing else can read or mutate the pointee while this MovingPtr is live.
Source

pub fn partial_move<R>( self, f: impl FnOnce(MovingPtr<'_, T, A>) -> R, ) -> (MovingPtr<'a, MaybeUninit<T>, A>, R)

Partially moves out some fields inside of self.

The partially returned value is returned back pointing to MaybeUninit<T>.

While calling this function is safe, care must be taken with the returned MovingPtr as it points to a value that may no longer be completely valid.

§Example
use core::mem::{offset_of, MaybeUninit, forget};
use bevy_ptr::{MovingPtr, move_as_ptr};

struct Parent {
  field_a: FieldAType,
  field_b: FieldBType,
  field_c: FieldCType,
}


// Converts `parent` into a `MovingPtr`
move_as_ptr!(parent);

// SAFETY:
// - `field_a` and `field_b` are both unique.
let (partial_parent, ()) = MovingPtr::partial_move(parent, |parent_ptr| unsafe {
  bevy_ptr::deconstruct_moving_ptr!({
    let Parent { field_a, field_b, field_c } = parent_ptr;
  });
   
  insert(field_a);
  insert(field_b);
  forget(field_c);
});

// Move the rest of fields out of the parent.
// SAFETY:
// - `field_c` is by itself unique and does not conflict with the previous accesses
//   inside `partial_move`.
unsafe {
  bevy_ptr::deconstruct_moving_ptr!({
    let MaybeUninit::<Parent> { field_a: _, field_b: _, field_c } = partial_parent;
  });

  insert(field_c);
}
Source

pub fn read(self) -> T

Reads the value pointed to by this pointer.

Source

pub unsafe fn write_to(self, dst: *mut T)

Writes the value pointed to by this pointer to a provided location.

This does not drop the value stored at dst and it’s the caller’s responsibility to ensure that it’s properly dropped.

§Safety
Source

pub fn assign_to(self, dst: &mut T)

Writes the value pointed to by this pointer into dst.

The value previously stored at dst will be dropped.

Source

pub unsafe fn move_field<U>( &self, f: impl Fn(*mut T) -> *mut U, ) -> MovingPtr<'a, U, A>

Creates a MovingPtr for a specific field within self.

This function is explicitly made for deconstructive moves.

The correct byte_offset for a field can be obtained via core::mem::offset_of.

§Safety
  • f must return a non-null pointer to a valid field inside T
  • If A is Aligned, then T must not be repr(packed)
  • self should not be accessed or dropped as if it were a complete value after this function returns. Other fields that have not been moved out of may still be accessed or dropped separately.
  • This function cannot alias the field with any other access, including other calls to move_field for the same field, without first calling forget on it first.

A result of the above invariants means that any operation that could cause self to be dropped while the pointers to the fields are held will result in undefined behavior. This requires exctra caution around code that may panic. See the example below for an example of how to safely use this function.

§Example
use core::mem::offset_of;
use bevy_ptr::{MovingPtr, move_as_ptr};

struct Parent {
  field_a: FieldAType,
  field_b: FieldBType,
  field_c: FieldCType,
}

let parent = Parent {
   field_a: FieldAType(0),
   field_b: FieldBType(0),
   field_c: FieldCType(0),
};

// Converts `parent` into a `MovingPtr`.
move_as_ptr!(parent);

unsafe {
   let field_a = parent.move_field(|ptr| &raw mut (*ptr).field_a);
   let field_b = parent.move_field(|ptr| &raw mut (*ptr).field_b);
   let field_c = parent.move_field(|ptr| &raw mut (*ptr).field_c);
   // Each call to insert may panic! Ensure that `parent_ptr` cannot be dropped before
   // calling them!
   core::mem::forget(parent);
   insert(field_a);
   insert(field_b);
   insert(field_c);
}
Source§

impl<'a, T, A> MovingPtr<'a, MaybeUninit<T>, A>
where A: IsAligned,

Source

pub unsafe fn move_maybe_uninit_field<U>( &self, f: impl Fn(*mut T) -> *mut U, ) -> MovingPtr<'a, MaybeUninit<U>, A>

Creates a MovingPtr for a specific field within self.

This function is explicitly made for deconstructive moves.

The correct byte_offset for a field can be obtained via core::mem::offset_of.

§Safety
  • f must return a non-null pointer to a valid field inside T
  • If A is Aligned, then T must not be repr(packed)
  • self should not be accessed or dropped as if it were a complete value after this function returns. Other fields that have not been moved out of may still be accessed or dropped separately.
  • This function cannot alias the field with any other access, including other calls to move_field for the same field, without first calling forget on it first.
Source§

impl<'a, T, A> MovingPtr<'a, MaybeUninit<T>, A>
where A: IsAligned,

Source

pub unsafe fn assume_init(self) -> MovingPtr<'a, T, A>

Creates a MovingPtr pointing to a valid instance of T.

See also: MaybeUninit::assume_init.

§Safety

It’s up to the caller to ensure that the value pointed to by self is really in an initialized state. Calling this when the content is not yet fully initialized causes immediate undefined behavior.

Trait Implementations§

Source§

impl<T> Debug for MovingPtr<'_, T>

Source§

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

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

impl<T> Debug for MovingPtr<'_, T, Unaligned>

Source§

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

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

impl<T> Deref for MovingPtr<'_, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<MovingPtr<'_, T> as Deref>::Target

Dereferences the value.
Source§

impl<T> DerefMut for MovingPtr<'_, T>

Source§

fn deref_mut(&mut self) -> &mut <MovingPtr<'_, T> as Deref>::Target

Mutably dereferences the value.
Source§

impl<T, A> Drop for MovingPtr<'_, T, A>
where A: IsAligned,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a, T, A> From<MovingPtr<'a, T, A>> for OwningPtr<'a, A>
where A: IsAligned,

Source§

fn from(value: MovingPtr<'a, T, A>) -> OwningPtr<'a, A>

Converts to this type from the input type.
Source§

impl<T, A> Pointer for MovingPtr<'_, T, A>
where A: IsAligned,

Source§

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

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

impl<'a, T> TryFrom<MovingPtr<'a, T, Unaligned>> for MovingPtr<'a, T>

Source§

type Error = MovingPtr<'a, T, Unaligned>

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

fn try_from( value: MovingPtr<'a, T, Unaligned>, ) -> Result<MovingPtr<'a, T>, <MovingPtr<'a, T> as TryFrom<MovingPtr<'a, T, Unaligned>>>::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'a, T, A> Freeze for MovingPtr<'a, T, A>

§

impl<'a, T, A> RefUnwindSafe for MovingPtr<'a, T, A>

§

impl<'a, T, A = Aligned> !Send for MovingPtr<'a, T, A>

§

impl<'a, T, A = Aligned> !Sync for MovingPtr<'a, T, A>

§

impl<'a, T, A> Unpin for MovingPtr<'a, T, A>
where A: Unpin,

§

impl<'a, T, A = Aligned> !UnwindSafe for MovingPtr<'a, T, A>

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, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

Source§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
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, C, D> Curve<T> for D
where C: Curve<T> + ?Sized, D: Deref<Target = C>,

Source§

fn domain(&self) -> Interval

The interval over which this curve is parametrized. Read more
Source§

fn sample_unchecked(&self, t: f32) -> T

Sample a point on this curve at the parameter value t, extracting the associated value. This is the unchecked version of sampling, which should only be used if the sample time t is already known to lie within the curve’s domain. Read more
Source§

fn sample(&self, t: f32) -> Option<T>

Sample a point on this curve at the parameter value t, returning None if the point is outside of the curve’s domain.
Source§

fn sample_clamped(&self, t: f32) -> T

Sample a point on this curve at the parameter value t, clamping t to lie inside the domain of the curve.
Source§

impl<C, T> CurveExt<T> for C
where C: Curve<T>,

Source§

fn sample_iter( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = Option<T>>

Sample a collection of n >= 0 points on this curve at the parameter values t_n, returning None if the point is outside of the curve’s domain. Read more
Source§

fn sample_iter_unchecked( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = T>

Sample a collection of n >= 0 points on this curve at the parameter values t_n, extracting the associated values. This is the unchecked version of sampling, which should only be used if the sample times t_n are already known to lie within the curve’s domain. Read more
Source§

fn sample_iter_clamped( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = T>

Sample a collection of n >= 0 points on this curve at the parameter values t_n, clamping t_n to lie inside the domain of the curve. Read more
Source§

fn map<S, F>(self, f: F) -> MapCurve<T, S, Self, F>
where F: Fn(T) -> S,

Create a new curve by mapping the values of this curve via a function f; i.e., if the sample at time t for this curve is x, the value at time t on the new curve will be f(x).
Source§

fn reparametrize<F>(self, domain: Interval, f: F) -> ReparamCurve<T, Self, F>
where F: Fn(f32) -> f32,

Create a new Curve whose parameter space is related to the parameter space of this curve by f. For each time t, the sample from the new curve at time t is the sample from this curve at time f(t). The given domain will be the domain of the new curve. The function f is expected to take domain into self.domain(). Read more
Source§

fn reparametrize_linear( self, domain: Interval, ) -> Result<LinearReparamCurve<T, Self>, LinearReparamError>

Linearly reparametrize this Curve, producing a new curve whose domain is the given domain instead of the current one. This operation is only valid for curves with bounded domains. Read more
Source§

fn reparametrize_by_curve<C>(self, other: C) -> CurveReparamCurve<T, Self, C>
where C: Curve<f32>,

Reparametrize this Curve by sampling from another curve. Read more
Source§

fn graph(self) -> GraphCurve<T, Self>

Create a new Curve which is the graph of this one; that is, its output echoes the sample time as part of a tuple. Read more
Source§

fn zip<S, C>( self, other: C, ) -> Result<ZipCurve<T, S, Self, C>, InvalidIntervalError>
where C: Curve<S>,

Create a new Curve by zipping this curve together with another. Read more
Source§

fn chain<C>(self, other: C) -> Result<ChainCurve<T, Self, C>, ChainError>
where C: Curve<T>,

Create a new Curve by composing this curve end-to-start with another, producing another curve with outputs of the same type. The domain of the other curve is translated so that its start coincides with where this curve ends. Read more
Source§

fn reverse(self) -> Result<ReverseCurve<T, Self>, ReverseError>

Create a new Curve inverting this curve on the x-axis, producing another curve with outputs of the same type, effectively playing backwards starting at self.domain().end() and transitioning over to self.domain().start(). The domain of the new curve is still the same. Read more
Source§

fn repeat(self, count: usize) -> Result<RepeatCurve<T, Self>, RepeatError>

Create a new Curve repeating this curve N times, producing another curve with outputs of the same type. The domain of the new curve will be bigger by a factor of n + 1. Read more
Source§

fn forever(self) -> Result<ForeverCurve<T, Self>, RepeatError>

Create a new Curve repeating this curve forever, producing another curve with outputs of the same type. The domain of the new curve will be unbounded. Read more
Source§

fn ping_pong(self) -> Result<PingPongCurve<T, Self>, PingPongError>

Create a new Curve chaining the original curve with its inverse, producing another curve with outputs of the same type. The domain of the new curve will be twice as long. The transition point is guaranteed to not make any jumps. Read more
Source§

fn chain_continue<C>( self, other: C, ) -> Result<ContinuationCurve<T, Self, C>, ChainError>
where T: VectorSpace, C: Curve<T>,

Create a new Curve by composing this curve end-to-start with another, producing another curve with outputs of the same type. The domain of the other curve is translated so that its start coincides with where this curve ends. Read more
Source§

fn samples( &self, samples: usize, ) -> Result<impl Iterator<Item = T>, ResamplingError>

Extract an iterator over evenly-spaced samples from this curve. Read more
Source§

fn by_ref(&self) -> &Self

Borrow this curve rather than taking ownership of it. This is essentially an alias for a prefix &; the point is that intermediate operations can be performed while retaining access to the original curve. Read more
Source§

fn flip<U, V>(self) -> impl Curve<(V, U)>
where Self: CurveExt<(U, V)>,

Flip this curve so that its tuple output is arranged the other way.
Source§

impl<C, T> CurveResampleExt<T> for C
where C: Curve<T> + ?Sized,

Source§

fn resample<I>( &self, segments: usize, interpolation: I, ) -> Result<SampleCurve<T, I>, ResamplingError>
where I: Fn(&T, &T, f32) -> T,

Resample this Curve to produce a new one that is defined by interpolation over equally spaced sample values, using the provided interpolation to interpolate between adjacent samples. The curve is interpolated on segments segments between samples. For example, if segments is 1, only the start and end points of the curve are used as samples; if segments is 2, a sample at the midpoint is taken as well, and so on. Read more
Source§

fn resample_auto( &self, segments: usize, ) -> Result<SampleAutoCurve<T>, ResamplingError>

Resample this Curve to produce a new one that is defined by interpolation over equally spaced sample values, using automatic interpolation to interpolate between adjacent samples. The curve is interpolated on segments segments between samples. For example, if segments is 1, only the start and end points of the curve are used as samples; if segments is 2, a sample at the midpoint is taken as well, and so on. Read more
Source§

fn resample_uneven<I>( &self, sample_times: impl IntoIterator<Item = f32>, interpolation: I, ) -> Result<UnevenSampleCurve<T, I>, ResamplingError>
where I: Fn(&T, &T, f32) -> T,

Resample this Curve to produce a new one that is defined by interpolation over samples taken at a given set of times. The given interpolation is used to interpolate adjacent samples, and the sample_times are expected to contain at least two valid times within the curve’s domain interval. Read more
Source§

fn resample_uneven_auto( &self, sample_times: impl IntoIterator<Item = f32>, ) -> Result<UnevenSampleAutoCurve<T>, ResamplingError>

Resample this Curve to produce a new one that is defined by automatic interpolation over samples taken at the given set of times. The given sample_times are expected to contain at least two valid times within the curve’s domain interval. Read more
Source§

impl<T, C> CurveWithDerivative<T> for C
where T: HasTangent, C: SampleDerivative<T>,

Source§

fn with_derivative(self) -> SampleDerivativeWrapper<C>

This curve, but with its first derivative included in sampling. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
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> 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> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
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<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<T, C, D> SampleDerivative<T> for D
where T: HasTangent, C: SampleDerivative<T> + ?Sized, D: Deref<Target = C>,

Source§

fn sample_with_derivative_unchecked(&self, t: f32) -> WithDerivative<T>

Sample this curve at the parameter value t, extracting the associated value in addition to its derivative. This is the unchecked version of sampling, which should only be used if the sample time t is already known to lie within the curve’s domain. Read more
Source§

fn sample_with_derivative(&self, t: f32) -> Option<WithDerivative<T>>

Sample this curve’s value and derivative at the parameter value t, returning None if the point is outside of the curve’s domain.
Source§

fn sample_with_derivative_clamped(&self, t: f32) -> WithDerivative<T>

Sample this curve’s value and derivative at the parameter value t, clamping t to lie inside the domain of the curve.
Source§

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

Source§

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

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<R> TryRngCore for R
where R: RngCore + ?Sized,

Source§

type Error = Infallible

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

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

Source§

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