Crate castaway

Source
Expand description

Safe, zero-cost downcasting for limited compile-time specialization.

This crate works fully on stable Rust, and also does not require the standard library. To disable references to the standard library, you must opt-out of the std feature using default-features = false in your Cargo.toml file. When in no-std mode, a separate alloc feature flag is available to support casting to several alloc types not included in core.

Castaway provides the following key macros:

  • cast: Attempt to cast the result of an expression into a given concrete type.
  • match_type: Match the result of an expression against multiple concrete types.

Macros§

cast
Attempt to cast the result of an expression into a given concrete type.
match_type
Match the result of an expression against multiple concrete types.

Traits§

LifetimeFree
Marker trait for types that do not contain any lifetime parameters. Such types are safe to cast from non-static type parameters if their types are equal.