pub struct BufRand<R: RngCore> {
pub rand: R,
/* private fields */
}Expand description
used to generate random booleans using a bit buffer
Fields§
§rand: Rthe inner randomizer of this BufRand. this is pub so it can be used after this BufRand has been Constructed
Implementations§
Source§impl<R: RngCore> BufRand<R>
impl<R: RngCore> BufRand<R>
Sourcepub fn new(rand: R) -> Self
pub fn new(rand: R) -> Self
create a new BufRand which generates random booleans using the
supplied rng
Examples found in repository?
More examples
Sourcepub fn next_bool(&mut self) -> bool
pub fn next_bool(&mut self) -> bool
returns a random boolean from the buffer of this BufRand
use buf_rand::BufRand;
let mut rand = BufRand::new(rand::thread_rng());
rand.next_bool();Sourcepub fn rand_char_case(&mut self, c: &char) -> String
pub fn rand_char_case(&mut self, c: &char) -> String
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(rand::thread_rng());
rand.rand_char_case(&'E');Sourcepub fn rand_string_case(&mut self, s: &str) -> String
pub fn rand_string_case(&mut self, s: &str) -> String
randomizes the capitalization of every character in the string
use buf_rand::BufRand;
let mut rand = BufRand::new(rand::thread_rng());
rand.rand_string_case("hello world!");Auto Trait Implementations§
impl<R> Freeze for BufRand<R>where
R: Freeze,
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> UnsafeUnpin for BufRand<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for BufRand<R>where
R: UnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more