Skip to content

Shouldn't NoError be uninhabited? #61

Description

@Rafferty97

According the docs, NoError is a type that can never be instantiated. But when I looked at the code, it's a struct with a "dummy field" rather than an actual uninhabited type. The benefit of using an uninhabited type is that it makes it literally impossible to instantiate, which the compiler can then exploit to generate better optimised code.

So, is there any reason NoError isn't defined as an uninhabited type? It's pretty simple to do, just use an enum with no variants:

#[derive(Debug)]
pub enum NoError {}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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