pub struct Seed {
    pub bytes: [u8; 32],
}
Expand description

A type representing a random seed.

Fields

bytes: [u8; 32]

Implementations

Creates a Seed from a slice of 32 bytes.

Worst-case complexity

Constant time and additional memory.

Examples
use malachite_base::random::Seed;

Seed::from_bytes([10; 32]);

Creates a PRNG from a slice of 32 bytes.

Worst-case complexity

Constant time and additional memory.

Examples
use malachite_base::random::EXAMPLE_SEED;

EXAMPLE_SEED.get_rng();

Uniformly generates a random Seed.

Worst-case complexity

Constant time and additional memory.

Examples
use malachite_base::random::Seed;
use malachite_base::random::EXAMPLE_SEED;

assert_eq!(
    EXAMPLE_SEED.next(),
    Seed::from_bytes([
        0x71, 0xef, 0x45, 0x6c, 0xe4, 0xd2, 0xa8, 0xa1, 0x57, 0x20, 0x6e, 0x53, 0xbc, 0x22,
        0x59, 0xee, 0x5d, 0xc8, 0x95, 0x73, 0xbd, 0x95, 0xd9, 0xc9, 0x75, 0x92, 0x1f, 0x48,
        0x97, 0xa9, 0xae, 0x21
    ])
);

Generates a new Seed from this seed. Passing different keys will, with very high probability, generate different seeds.

Worst-case complexity

Constant time and additional memory.

Examples
use malachite_base::random::Seed;
use malachite_base::random::EXAMPLE_SEED;

assert_eq!(
    EXAMPLE_SEED.fork("first"),
    Seed::from_bytes([
        0x20, 0x18, 0x1, 0x3d, 0x96, 0x4d, 0x3e, 0x98, 0x10, 0x9d, 0x35, 0x75, 0x22, 0x89,
        0xf7, 0xe9, 0xbe, 0x2f, 0x9c, 0x15, 0x95, 0x42, 0x1a, 0x79, 0x52, 0xf, 0x56, 0x9a,
        0x7b, 0x8c, 0xd9, 0x34
    ])
);
assert_eq!(
    EXAMPLE_SEED.fork("second"),
    Seed::from_bytes([
        0xe0, 0x36, 0x88, 0x58, 0x6d, 0x67, 0x33, 0xea, 0xf2, 0x1c, 0x88, 0xf9, 0xe3, 0xbd,
        0x52, 0xc0, 0xe5, 0xad, 0x61, 0x81, 0x21, 0xd8, 0x2f, 0x8e, 0xcd, 0xf, 0x89, 0x9d,
        0x32, 0xc5, 0x35, 0x83
    ])
);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

Returns the String produced by Ts Debug implementation.

Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.