Sha256: bdb69915fe12a9e0b8f2ab4d72466663b7a3e87e671343a0a623028690f4e452

Contents?: true

Size: 492 Bytes

Versions: 30

Compression:

Stored size: 492 Bytes

Contents

use super::RngSeed;

use std::collections::hash_map::DefaultHasher;
use std::hash::Hasher;

impl RngSeed {
    /// Generates a seed from the provided byte slice.
    ///
    /// # Example
    ///
    /// ```
    /// # use tokio::runtime::RngSeed;
    /// let seed = RngSeed::from_bytes(b"make me a seed");
    /// ```
    pub fn from_bytes(bytes: &[u8]) -> Self {
        let mut hasher = DefaultHasher::default();
        hasher.write(bytes);
        Self::from_u64(hasher.finish())
    }
}

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/tokio-1.43.0/src/util/rand/rt_unstable.rs
wasmtime-28.0.0 ./ext/cargo-vendor/tokio-1.43.0/src/util/rand/rt_unstable.rs
wasmtime-27.0.0 ./ext/cargo-vendor/tokio-1.41.1/src/util/rand/rt_unstable.rs
wasmtime-26.0.0 ./ext/cargo-vendor/tokio-1.41.0/src/util/rand/rt_unstable.rs
wasmtime-25.0.2 ./ext/cargo-vendor/tokio-1.40.0/src/util/rand/rt_unstable.rs
wasmtime-25.0.1 ./ext/cargo-vendor/tokio-1.39.3/src/util/rand/rt_unstable.rs
wasmtime-25.0.0 ./ext/cargo-vendor/tokio-1.39.3/src/util/rand/rt_unstable.rs
wasmtime-24.0.0 ./ext/cargo-vendor/tokio-1.39.3/src/util/rand/rt_unstable.rs
wasmtime-23.0.2 ./ext/cargo-vendor/tokio-1.36.0/src/util/rand/rt_unstable.rs
wasmtime-22.0.0 ./ext/cargo-vendor/tokio-1.36.0/src/util/rand/rt_unstable.rs
wasmtime-21.0.1 ./ext/cargo-vendor/tokio-1.36.0/src/util/rand/rt_unstable.rs
wasmtime-20.0.2 ./ext/cargo-vendor/tokio-1.36.0/src/util/rand/rt_unstable.rs
wasmtime-20.0.0 ./ext/cargo-vendor/tokio-1.36.0/src/util/rand/rt_unstable.rs
wasmtime-18.0.3 ./ext/cargo-vendor/tokio-1.36.0/src/util/rand/rt_unstable.rs
wasmtime-17.0.1 ./ext/cargo-vendor/tokio-1.35.1/src/util/rand/rt_unstable.rs
wasmtime-17.0.0 ./ext/cargo-vendor/tokio-1.35.1/src/util/rand/rt_unstable.rs
wasmtime-16.0.0 ./ext/cargo-vendor/tokio-1.35.1/src/util/rand/rt_unstable.rs
wasmtime-15.0.1 ./ext/cargo-vendor/tokio-1.35.1/src/util/rand/rt_unstable.rs
wasmtime-15.0.0 ./ext/cargo-vendor/tokio-1.35.1/src/util/rand/rt_unstable.rs
wasmtime-14.0.4 ./ext/cargo-vendor/tokio-1.33.0/src/util/rand/rt_unstable.rs