Skip to content

Explain how enum variants are also constructors for the enum type #800

Description

given the following enum

enum Number {
  Int(i32),
  Float(f32)
}

The following expression Number::Int fulfills the FnOnce(i32) -> Number trait.
(same for the Float variant)

Maybe there is a good spot to mention this in the new book?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions