-
Notifications
You must be signed in to change notification settings - Fork 142
Open
Labels
compatibility-breakingChanges that are (likely to be) breakingChanges that are (likely to be) breaking
Description
Once the associated_const_equality feature is stabilized, we ought to be able to automatically implement Unaligned without needing a custom derive:
#![feature(associated_const_equality)]
unsafe trait Align {
const ALIGN: usize;
}
unsafe impl<T> Align for T {
const ALIGN: usize = core::mem::align_of::<T>();
}
unsafe trait Unaligned {}
unsafe impl<T: Align<ALIGN = 1>> Unaligned for T {}Note that we may not want to do this - it would mean that types would no longer need to opt-in to implementing Unaligned as they do today. This probably isn't a huge deal since you can't do anything with Unaligned on its own (FromBytes and AsBytes are the traits that really unlock the ability to muck with a type's internal state), but at a minimum it would make the API inconsistent. One option would be to just make Align<ALIGN = 1> a bound so that Unaligned could become a safe trait that just represents the fact of opting-in:
trait Unaligned: Align<ALIGN = 1> {}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
compatibility-breakingChanges that are (likely to be) breakingChanges that are (likely to be) breaking