ref-cast

Safely cast &T to &U where the struct U contains a single field of type T. (by dtolnay)

Ref-cast Alternatives

Similar projects and alternatives to ref-cast

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a better ref-cast alternative or higher similarity.

ref-cast reviews and mentions

Posts with mentions or reviews of ref-cast. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-01-30.
  • create a &Struct for a &Value
    1 project | /r/rust | 30 Apr 2023
    Yes, that's possible if you use repr(transparent). And as always David Tolnay has a crate for that: https://github.com/dtolnay/ref-cast
  • When Rust hurts
    1 project | /r/programming | 17 Feb 2023
    Actually you can, as long as the newtype struct has #[repr(transparent)]. The ref-cast crate makes it easy to do this without having to (directly) use unsafe code!
  • Hey Rustaceans! Got a question? Ask here (5/2023)!
    19 projects | /r/rust | 30 Jan 2023
    You can add #[repr(transparent)] and then call transmute(), or use https://github.com/dtolnay/ref-cast (which is exactly what it does anyway, providing a safe interface).
  • A note from our sponsor - WorkOS
    workos.com | 25 Apr 2024
    The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning. Learn more →

Stats

Basic ref-cast repo stats
3
174
7.3
17 days ago

dtolnay/ref-cast is an open source project licensed under Apache License 2.0 which is an OSI approved license.

The primary programming language of ref-cast is Rust.


Sponsored
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com