|
|
Subscribe / Log in / New account

Transmute to user-defined types with all public fields?

Transmute to user-defined types with all public fields?

Posted Oct 25, 2024 0:49 UTC (Fri) by roc (subscriber, #30627)
In reply to: Transmute to user-defined types with all public fields? by heftig
Parent article: Toward safe transmutation in Rust

Fine, a user-defined type with all public fields and no padding should be a valid transmutation target if its fields are


to post comments

Transmute to user-defined types with all public fields?

Posted Oct 26, 2024 15:27 UTC (Sat) by asahilina (subscriber, #166071) [Link]

That is the simplified version and what is already being done with macros in certain crates: you can transmute into types where all bit patterns are valid. But what is being researched here seems to be more general, e.g. you would in theory be able to transmute [NonZeroU8; 4] into NonZeroU32, though not vice versa, despite neither type having all bit patterns valid.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds