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
isAligned
, the pointer must always be properly aligned for the typeT
.
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>
impl<'a, T> MovingPtr<'a, T>
Sourcepub fn to_unaligned(self) -> MovingPtr<'a, T, Unaligned>
pub fn to_unaligned(self) -> MovingPtr<'a, T, Unaligned>
Removes the alignment requirement of this pointer
Sourcepub unsafe fn from_value(value: &'a mut MaybeUninit<T>) -> MovingPtr<'a, T>
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 typeT
.- Once the returned
MovingPtr
has been used,value
must be treated as it were uninitialized unless it was explicitly leaked viacore::mem::forget
.
Source§impl<'a, T, A> MovingPtr<'a, T, A>where
A: IsAligned,
impl<'a, T, A> MovingPtr<'a, T, A>where
A: IsAligned,
Sourcepub unsafe fn new(inner: NonNull<T>) -> MovingPtr<'a, T, A>
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 ofT
.- If the
A
type parameter isAligned
theninner
must be be properly aligned forT
. inner
must have correct provenance to allow read and writes of the pointee type.- The lifetime
'a
must be constrained such that thisMovingPtr
will stay valid and nothing else can read or mutate the pointee while thisMovingPtr
is live.
Sourcepub fn partial_move<R>(
self,
f: impl FnOnce(MovingPtr<'_, T, A>) -> R,
) -> (MovingPtr<'a, MaybeUninit<T>, A>, R)
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);
}
Sourcepub unsafe fn write_to(self, dst: *mut T)
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
dst
must be valid for writes.- If the
A
type parameter isAligned
thendst
must be properly aligned forT
.
Sourcepub fn assign_to(self, dst: &mut T)
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.
Sourcepub unsafe fn move_field<U>(
&self,
f: impl Fn(*mut T) -> *mut U,
) -> MovingPtr<'a, U, A>
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 insideT
- If
A
isAligned
, thenT
must not berepr(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 callingforget
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,
impl<'a, T, A> MovingPtr<'a, MaybeUninit<T>, A>where
A: IsAligned,
Sourcepub unsafe fn move_maybe_uninit_field<U>(
&self,
f: impl Fn(*mut T) -> *mut U,
) -> MovingPtr<'a, MaybeUninit<U>, A>
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 insideT
- If
A
isAligned
, thenT
must not berepr(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 callingforget
on it first.
Source§impl<'a, T, A> MovingPtr<'a, MaybeUninit<T>, A>where
A: IsAligned,
impl<'a, T, A> MovingPtr<'a, MaybeUninit<T>, A>where
A: IsAligned,
Sourcepub unsafe fn assume_init(self) -> MovingPtr<'a, T, A>
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§
Auto Trait Implementations§
impl<'a, T, A> Freeze for MovingPtr<'a, T, A>
impl<'a, T, A> RefUnwindSafe for MovingPtr<'a, T, A>where
T: RefUnwindSafe,
A: RefUnwindSafe,
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, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.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<T, C, D> Curve<T> for D
impl<T, C, D> Curve<T> for D
Source§fn sample_unchecked(&self, t: f32) -> T
fn sample_unchecked(&self, t: f32) -> T
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 moreSource§fn sample(&self, t: f32) -> Option<T>
fn sample(&self, t: f32) -> Option<T>
t
, returning None
if the point is
outside of the curve’s domain.Source§fn sample_clamped(&self, t: f32) -> T
fn sample_clamped(&self, t: f32) -> T
t
, clamping t
to lie inside the
domain of the curve.Source§impl<C, T> CurveExt<T> for Cwhere
C: Curve<T>,
impl<C, T> CurveExt<T> for Cwhere
C: Curve<T>,
Source§fn sample_iter(
&self,
iter: impl IntoIterator<Item = f32>,
) -> impl Iterator<Item = Option<T>>
fn sample_iter( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = Option<T>>
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 moreSource§fn sample_iter_unchecked(
&self,
iter: impl IntoIterator<Item = f32>,
) -> impl Iterator<Item = T>
fn sample_iter_unchecked( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = T>
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 moreSource§fn sample_iter_clamped(
&self,
iter: impl IntoIterator<Item = f32>,
) -> impl Iterator<Item = T>
fn sample_iter_clamped( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = T>
n >= 0
points on this curve at the parameter values t_n
,
clamping t_n
to lie inside the domain of the curve. Read moreSource§fn map<S, F>(self, f: F) -> MapCurve<T, S, Self, F>where
F: Fn(T) -> S,
fn map<S, F>(self, f: F) -> MapCurve<T, S, Self, F>where
F: Fn(T) -> S,
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>
fn reparametrize<F>(self, domain: Interval, f: F) -> ReparamCurve<T, Self, F>
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 moreSource§fn reparametrize_linear(
self,
domain: Interval,
) -> Result<LinearReparamCurve<T, Self>, LinearReparamError>
fn reparametrize_linear( self, domain: Interval, ) -> Result<LinearReparamCurve<T, Self>, LinearReparamError>
Source§fn reparametrize_by_curve<C>(self, other: C) -> CurveReparamCurve<T, Self, C>
fn reparametrize_by_curve<C>(self, other: C) -> CurveReparamCurve<T, Self, C>
Source§fn graph(self) -> GraphCurve<T, Self>
fn graph(self) -> GraphCurve<T, Self>
Source§fn zip<S, C>(
self,
other: C,
) -> Result<ZipCurve<T, S, Self, C>, InvalidIntervalError>where
C: Curve<S>,
fn zip<S, C>(
self,
other: C,
) -> Result<ZipCurve<T, S, Self, C>, InvalidIntervalError>where
C: Curve<S>,
Source§fn chain<C>(self, other: C) -> Result<ChainCurve<T, Self, C>, ChainError>where
C: Curve<T>,
fn chain<C>(self, other: C) -> Result<ChainCurve<T, Self, C>, ChainError>where
C: Curve<T>,
Source§fn reverse(self) -> Result<ReverseCurve<T, Self>, ReverseError>
fn reverse(self) -> Result<ReverseCurve<T, Self>, ReverseError>
Source§fn repeat(self, count: usize) -> Result<RepeatCurve<T, Self>, RepeatError>
fn repeat(self, count: usize) -> Result<RepeatCurve<T, Self>, RepeatError>
Source§fn forever(self) -> Result<ForeverCurve<T, Self>, RepeatError>
fn forever(self) -> Result<ForeverCurve<T, Self>, RepeatError>
Source§fn ping_pong(self) -> Result<PingPongCurve<T, Self>, PingPongError>
fn ping_pong(self) -> Result<PingPongCurve<T, Self>, PingPongError>
Source§fn chain_continue<C>(
self,
other: C,
) -> Result<ContinuationCurve<T, Self, C>, ChainError>where
T: VectorSpace,
C: Curve<T>,
fn chain_continue<C>(
self,
other: C,
) -> Result<ContinuationCurve<T, Self, C>, ChainError>where
T: VectorSpace,
C: Curve<T>,
Source§fn samples(
&self,
samples: usize,
) -> Result<impl Iterator<Item = T>, ResamplingError>
fn samples( &self, samples: usize, ) -> Result<impl Iterator<Item = T>, ResamplingError>
Source§impl<C, T> CurveResampleExt<T> for C
impl<C, T> CurveResampleExt<T> for C
Source§fn resample<I>(
&self,
segments: usize,
interpolation: I,
) -> Result<SampleCurve<T, I>, ResamplingError>
fn resample<I>( &self, segments: usize, interpolation: I, ) -> Result<SampleCurve<T, I>, ResamplingError>
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 moreSource§fn resample_auto(
&self,
segments: usize,
) -> Result<SampleAutoCurve<T>, ResamplingError>where
T: StableInterpolate,
fn resample_auto(
&self,
segments: usize,
) -> Result<SampleAutoCurve<T>, ResamplingError>where
T: StableInterpolate,
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 moreSource§fn resample_uneven<I>(
&self,
sample_times: impl IntoIterator<Item = f32>,
interpolation: I,
) -> Result<UnevenSampleCurve<T, I>, ResamplingError>
fn resample_uneven<I>( &self, sample_times: impl IntoIterator<Item = f32>, interpolation: I, ) -> Result<UnevenSampleCurve<T, I>, ResamplingError>
Source§fn resample_uneven_auto(
&self,
sample_times: impl IntoIterator<Item = f32>,
) -> Result<UnevenSampleAutoCurve<T>, ResamplingError>where
T: StableInterpolate,
fn resample_uneven_auto(
&self,
sample_times: impl IntoIterator<Item = f32>,
) -> Result<UnevenSampleAutoCurve<T>, ResamplingError>where
T: StableInterpolate,
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 moreSource§impl<T, C> CurveWithDerivative<T> for Cwhere
T: HasTangent,
C: SampleDerivative<T>,
impl<T, C> CurveWithDerivative<T> for Cwhere
T: HasTangent,
C: SampleDerivative<T>,
Source§fn with_derivative(self) -> SampleDerivativeWrapper<C>
fn with_derivative(self) -> SampleDerivativeWrapper<C>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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 Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§impl<R> Rng for R
impl<R> Rng for R
Source§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
StandardUniform
distribution. Read moreSource§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T> ⓘ
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T> ⓘ
Source§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Source§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
p
of being true. Read moreSource§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
numerator/denominator
of being
true. Read moreSource§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Source§fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T> ⓘwhere
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T> ⓘwhere
D: Distribution<T>,
Self: Sized,
Source§fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
random
to avoid conflict with the new gen
keyword in Rust 2024.Rng::random
.Source§fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
random_range
Rng::random_range
.Source§impl<T, C, D> SampleDerivative<T> for D
impl<T, C, D> SampleDerivative<T> for D
Source§fn sample_with_derivative_unchecked(&self, t: f32) -> WithDerivative<T>
fn sample_with_derivative_unchecked(&self, t: f32) -> WithDerivative<T>
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 moreSource§fn sample_with_derivative(&self, t: f32) -> Option<WithDerivative<T>>
fn sample_with_derivative(&self, t: f32) -> Option<WithDerivative<T>>
t
, returning
None
if the point is outside of the curve’s domain.Source§fn sample_with_derivative_clamped(&self, t: f32) -> WithDerivative<T>
fn sample_with_derivative_clamped(&self, t: f32) -> WithDerivative<T>
t
, clamping t
to lie inside the domain of the curve.Source§impl<R> TryRngCore for R
impl<R> TryRngCore for R
Source§type Error = Infallible
type Error = Infallible
Source§fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
u32
.Source§fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
u64
.Source§fn try_fill_bytes(
&mut self,
dst: &mut [u8],
) -> Result<(), <R as TryRngCore>::Error>
fn try_fill_bytes( &mut self, dst: &mut [u8], ) -> Result<(), <R as TryRngCore>::Error>
dest
entirely with random data.Source§fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
UnwrapMut
wrapper.Source§fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
RngCore
to a RngReadAdapter
.