Struct UniformUsize

pub struct UniformUsize { /* private fields */ }

The back-end implementing UniformSampler for usize.

Implementation notes

Sampling a usize value is usually used in relation to the length of an array or other memory structure, thus it is reasonable to assume that the vast majority of use-cases will have a maximum size under u32::MAX. In part to optimise for this use-case, but mostly to ensure that results are portable across 32-bit and 64-bit architectures (as far as is possible), this implementation will use 32-bit sampling when possible.

Trait Implementations

impl Clone for UniformUsize

fn clone(&self) -> UniformUsize

impl Copy for UniformUsize

impl Debug for UniformUsize

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

impl Eq for UniformUsize

impl PartialEq for UniformUsize

fn eq(&self, other: &UniformUsize) -> bool

impl Serialize for UniformUsize

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where
    __S: Serializer,

impl StructuralPartialEq for UniformUsize

impl UniformSampler for UniformUsize

type X = usize;
fn new<B1, B2>(low_b: B1, high_b: B2) -> Result<Self, Error>
where
    B1: SampleBorrow<Self::X> + Sized,
    B2: SampleBorrow<Self::X> + Sized,
fn new_inclusive<B1, B2>(low_b: B1, high_b: B2) -> Result<Self, Error>
where
    B1: SampleBorrow<Self::X> + Sized,
    B2: SampleBorrow<Self::X> + Sized,
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> usize
fn sample_single<R: Rng + ?Sized, B1, B2>(low_b: B1, high_b: B2, rng: &mut R) -> Result<Self::X, Error>
where
    B1: SampleBorrow<Self::X> + Sized,
    B2: SampleBorrow<Self::X> + Sized,
fn sample_single_inclusive<R: Rng + ?Sized, B1, B2>(low_b: B1, high_b: B2, rng: &mut R) -> Result<Self::X, Error>
where
    B1: SampleBorrow<Self::X> + Sized,
    B2: SampleBorrow<Self::X> + Sized,

impl<'de> Deserialize<'de> for UniformUsize

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where
    __D: Deserializer<'de>,

Auto Trait Implementations

impl Freeze for UniformUsize

impl RefUnwindSafe for UniformUsize

impl Send for UniformUsize

impl Sync for UniformUsize

impl Unpin for UniformUsize

impl UnsafeUnpin for UniformUsize

impl UnwindSafe for UniformUsize

Blanket Implementations

impl<T> Any for UniformUsize where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for UniformUsize where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for UniformUsize where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

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

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

impl<T> DeserializeOwned for UniformUsize where T: for<'de> Deserialize<'de>,

impl<T> From<T> for UniformUsize

fn from(t: T) -> T

Returns the argument unchanged.

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

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for UniformUsize where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

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

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for UniformUsize where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>