Registry / utility / ref-cast

ref-cast

JSON →
library1.0.25rscratesunverified

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

# Cargo.toml [dependencies] ref-cast = "1.0.25"
INSTALL
IMPORT
SIG · REF-CAST
R
ref-cast
utilityrustv1.0.25
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RefCast
use ref_cast::RefCast;

Casts a &u32 to &MyType safely.

use ref_cast::RefCast; #[derive(RefCast)] #[repr(transparent)] struct MyType(u32); let value = 42u32; let my_ref: &MyType = MyType::ref_cast(&value); assert_eq!(my_ref.0, 42);
Debug
Known issues

No known issues recorded.

Upgrade
Version history
1.0.25latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
ref-cast — cargo add ref-cast · libregistry