Crate castaway[][src]

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.

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. If the expression is in fact of the given type, an Ok is returned containing the result of the expression as that type. If the types do not match, the value is returned in an Err unchanged.

match_type

Match the result of an expression against multiple concrete types. You can write multiple match arms in the following syntax: