[][src]Struct buf_rand::BufRand

pub struct BufRand<R: RngCore> { /* fields omitted */ }

used to generate random booleans using a bit buffer

Implementations

impl<R: RngCore> BufRand<R>[src]

pub fn new(rand: R) -> Self[src]

create a new BufRand which generates random booleans using the supplied rng

pub fn next_bool(&mut self) -> bool[src]

returns a random boolean from the buffer of this BufRand

use buf_rand::BufRand;
 
let mut rand = BufRand::new(Box::new(rand::thread_rng()));
rand.next_bool();

pub fn rand_char_case(&mut self, c: &char) -> String[src]

randomizes the capitalization of a char this returns a String since some chars may result in multiple when the case is changed such as this

//example of character turning into multiple
assert_eq!('ß'.to_uppercase().to_string(), "SS");
use buf_rand::BufRand;
 
let mut rand = BufRand::new(Box::new(rand::thread_rng()));
rand.rand_char_case(&'E');

pub fn rand_string_case(&mut self, s: &str) -> String[src]

randomizes the capitalization of every character in the string

use buf_rand::BufRand;
 
let mut rand = BufRand::new(Box::new(rand::thread_rng()));
rand.rand_string_case("hello world!");

Trait Implementations

impl<R: RngCore> Deref for BufRand<R>[src]

type Target = R

The resulting type after dereferencing.

fn deref(&self) -> &Self::Target[src]

allows borrowing the randomizer this BufRand uses

impl<R: RngCore> DerefMut for BufRand<R>[src]

Auto Trait Implementations

impl<R> RefUnwindSafe for BufRand<R> where
    R: RefUnwindSafe

impl<R> Send for BufRand<R> where
    R: Send

impl<R> Sync for BufRand<R> where
    R: Sync

impl<R> Unpin for BufRand<R> where
    R: Unpin

impl<R> UnwindSafe for BufRand<R> where
    R: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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