Crate typeswitch

Crate typeswitch 

Source
Expand description

§TypeSwitch

typeswitch provides a powerful, Go-inspired macro to perform runtime type switching on dyn Any trait objects in Rust.

While Rust’s match statement is powerful for enums, it cannot natively branch based on the concrete type of a trait object. This crate bridges that gap with a clean, block-based syntax that supports:

  • Immutable and Mutable access to the underlying data.
  • Owned Consumption: Move values out of a Box<dyn Any>.
  • Go-style Binding: Automatically bind the downcasted value to a variable for all branches.
  • Or-Patterns: Match against multiple types in a single branch.

Macros§

typeswitch
A powerful macro to emulate a type switch statement for dyn Any trait objects.