castaway

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

MIT License

Downloads
13.6M
Stars
128
Committers
4
castaway - Fix tests requiring std to be conditional Latest Release

Published by sagebind over 2 years ago

Fixed

  • Ensure that any test or example that requires std in order to compile and run are conditionally compiled behind the std crate feature. (#8, #9)
castaway - Implement LifetimeFree for NonZeroUsize

Published by sagebind over 2 years ago

Added

  • Implement LifetimeFree for NonZeroUsize to allow casting to NonZeroUsize from non-'static sources which was missing in the prior release. (#7)
castaway - Non-static casts for limited lifetime-free types

Published by sagebind over 2 years ago

Breaking changes

  • A new std crate feature has been added which is enabled by default. To compile castaway in no_std contexts this feature must be enabled using default-features = false.

Added

  • You can now cast to certain types known to be lifetime-free (such as primitive types, String, common wrapper types, etc) in certain contexts, even if the source value is generic without a 'static bound. It is possible to cast this way to any type implementing the newly-introduced LifetimeFree trait. (#5, #6)
castaway - Allow casting slices

Published by sagebind almost 3 years ago

Added

  • Allow for casting slices and mutable slices of static item types. (#2)
castaway - Result name resolution fix

Published by sagebind about 3 years ago

Fixed

  • Fix Result not being imported properly in macros, which could result in compilation errors when Result currently refers to another type in the scope invoked.
castaway - Initial release

Published by sagebind over 3 years ago

This is the first release of Castaway. This has the following changes from Castaway's predecessor Transmogrify:

  • Casting is performed with a macro instead of a trait. This improves ergonomics by removing the need to always use a turbofish, allows for more intelligent casting of references, and shrinks the public API to allow for taking advantage of future Rust features to allow for more types of casts without breaking changes.
  • The match_type macro now has a slightly different syntax, and match arms must now use irrefutable patterns.