{"id":58088,"library":"ref-cast","title":"Ref Cast","description":"Safely cast &T to &U where the struct U contains a single field of type T.","status":"active","version":"1.0.25","language":"rust","source_language":null,"source_url":"https://github.com/dtolnay/ref-cast","tags":["cast","safe","transparent","zero-cost"],"install":[{"cmd":"# Cargo.toml\n[dependencies]\nref-cast = \"1.0.25\"","lang":"toml","label":"Cargo.toml"},{"cmd":"cargo add ref-cast","lang":"bash","label":"cargo add"}],"dependencies":[],"imports":[{"symbol":"RefCast","correct":"use ref_cast::RefCast;"}],"quickstart":{"code":"use ref_cast::RefCast;\n\n#[derive(RefCast)]\n#[repr(transparent)]\nstruct MyType(u32);\n\nlet value = 42u32;\nlet my_ref: &MyType = MyType::ref_cast(&value);\nassert_eq!(my_ref.0, 42);","lang":"rust","description":"Casts a &u32 to &MyType safely."},"warnings":[],"env_vars":null,"search_vec":"'cast':2,4,19 'contain':12 'cost':24 'field':15 'ref':1 'safe':3,20 'singl':14 'struct':10 'transpar':21 'type':17 'u':7,11 'zero':23 'zero-cost':22","created_at":"2026-06-16T16:10:44.485217+00:00","updated_at":"2026-06-16T16:10:44.485217+00:00","problems":[],"ecosystem":"crates","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/dtolnay/ref-cast","github":"https://github.com/dtolnay/ref-cast","docs":"https://docs.rs/ref-cast/","changelog":null,"pypi":null,"npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["utility"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-16","next_check":"2026-12-13","install_tag":null}}