Struct javarandom::JavaRandom
source · pub struct JavaRandom { /* private fields */ }
Expand description
Rust implementation of the java.util.Random
class.
Implementations§
source§impl JavaRandom
impl JavaRandom
sourcepub fn new() -> JavaRandom
pub fn new() -> JavaRandom
Creates a new JavaRandom instance with a random seed.
sourcepub fn with_seed(seed: i64) -> JavaRandom
pub fn with_seed(seed: i64) -> JavaRandom
Creates a new JavaRandom instance with a given seed.
sourcepub fn set_seed(&mut self, seed: i64)
pub fn set_seed(&mut self, seed: i64)
Set the seed of this JavaRandom instance. This is identical to creating a new instance with the given seed.
sourcepub fn next_bytes(&mut self, bytes: &mut Vec<u8>)
pub fn next_bytes(&mut self, bytes: &mut Vec<u8>)
Replace the content of bytes with the next random bytes.
sourcepub fn next_int(&mut self) -> i32
pub fn next_int(&mut self) -> i32
Get a random i32 from this JavaRandom instance
For generating a random int with a bound, see [next_int_with_bound
]
sourcepub fn next_int_with_bound(&mut self, bound: u32) -> i32
pub fn next_int_with_bound(&mut self, bound: u32) -> i32
Get a random i32 from this JavaRandom instance with a bound
sourcepub fn next_boolean(&mut self) -> bool
pub fn next_boolean(&mut self) -> bool
Get a random bool from this JavaRandom instance.
sourcepub fn next_float(&mut self) -> f32
pub fn next_float(&mut self) -> f32
Get a random f32 from this JavaRandom instance
sourcepub fn next_double(&mut self) -> f64
pub fn next_double(&mut self) -> f64
Get a random f64 from this JavaRandom instance.
Trait Implementations§
source§impl Clone for JavaRandom
impl Clone for JavaRandom
source§fn clone(&self) -> JavaRandom
fn clone(&self) -> JavaRandom
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for JavaRandom
impl Debug for JavaRandom
source§impl Default for JavaRandom
impl Default for JavaRandom
source§fn default() -> JavaRandom
fn default() -> JavaRandom
Returns the “default value” for a type. Read more
source§impl Hash for JavaRandom
impl Hash for JavaRandom
source§impl PartialEq for JavaRandom
impl PartialEq for JavaRandom
source§fn eq(&self, other: &JavaRandom) -> bool
fn eq(&self, other: &JavaRandom) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for JavaRandom
impl StructuralPartialEq for JavaRandom
Auto Trait Implementations§
impl RefUnwindSafe for JavaRandom
impl Send for JavaRandom
impl Sync for JavaRandom
impl Unpin for JavaRandom
impl UnwindSafe for JavaRandom
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