Skip to content

aead: generate_nonce accept an immutable rng #1087

Closed
@alxiong

Description

@alxiong

I'm a little confused by the latest AeadCore::generate_nonce() API:

in code, it seems to be

    #[cfg(feature = "rand_core")]
    #[cfg_attr(docsrs, doc(cfg(feature = "rand_core")))]
    fn generate_nonce(mut rng: impl CryptoRng + RngCore) -> Nonce<Self>
    where
        Nonce<Self>: Default,
    {
        let mut nonce = Nonce::<Self>::default();
        rng.fill_bytes(&mut nonce);
        nonce
    }

however in rustdoc (latest/v0.5.1), it seem to be accepting an immutable rng: fn generate_nonce(rng: impl CryptoRng + RngCore) -> Nonce<Self>

that's the first confusion.

The second confusion is, why does it accept mut rng instead of &mut rng?

Metadata

Metadata

Assignees

No one assigned

    Labels

    aeadAuthenticated Encryption with Associated Data (AEAD) crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions