Skip to content

rand_core:0.5.0::Error has no raison d'etre #837

Closed
@nagisa

Description

@nagisa

The rand_core:0.5.0::Error is reduced down to an integer code, which has exactly as much value as no error at all. The stored integer carries no information whatsoever (esp. in generic contexts) and the error, if Displayed conveys no useful information either.

Consider for example:

fn foo<R: RandCore>(rng: R) {
    match rng.try_fill_bytes(...) {
        Err(e) => {
            // In this context "error code 42" is about as useful as 
            // "an error has occurred" or "bad things happened"
            //
            // Furthermore, each implementation of `RngCore` can map 
            // error numbers to causes in arbitrary ways, which makes 
            // whatever interpretation that could be derived in this generic
            // context misleadingly wrong, even.
        }
    }
}

With that in mind, the next version should reconsider this API change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions