Crate vesta

Source
Expand description

Rust license: MIT crates.io docs.rs documentation

A vesta, otherwise known as a match case, is a small container for matches, named after the Roman goddess of the hearth.

Vesta is a crate for extensibly matching cases in Rust.

By implementing Match and Case for some type (or better yet, correctly deriving them using the Match derive macro), you can pattern-match on that type using the case! macro almost like using the match keyword built into Rust.

However, Vesta’s case! macro is more general than match, because Match and Case are traits! This means you can enable pattern-matching for types which are not literally implemented as enums, and you can write code which is generic over any type that is pattern-matchable.

Macros§

  • Match on the cases of a value implementing Match.

Enums§

  • A marker type indicating that the tag for some type will always be strictly less than N.
  • A marker type indicating that the tag for some type is not fixed to some known upper bound.

Traits§

  • An implementation of Case defines a particular case of a pattern match for a type.
    ℹ️ Prefer using the methods of CaseExt to directly calling these methods.
  • An extension trait providing methods analogous to those in Case, but which take self and type parameters.
    💡 Prefer using these to directly calling the methods in Case.
  • A type which is Match can be pattern-matched using the case! macro and the methods of CaseExt/Case.

Functions§

  • Statically assert that the type of the given value is exhaustive for N.

Derive Macros§

  • Derive correct and efficient instances of Match and Case for a given struct or enum.