-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
new traitProposal for a new trait to be addedProposal for a new trait to be added
Description
Having some sort of trait for talking about a type's alignment at the type level will be useful not only for safe transmute but for other things as well. This information is often known at compile time and available through const functions.
One question is whether we need a general AlignmentOf<T> trait or if it is useful enough to have an AlignmentOfOne (a.k.a. Unaligned) for types where there are no alignment concerns and any reference to T: AlignmentOfOne is valid.
This is one possible area where const generics can help:
trait Alignment {
type Amount = const usize;
}
impl Alignment for u8 {
type Amount = 1;
}PriorArt
zerocopyprovidesUnalignedfor declaring that a type has no alignment concerns. It does not try to generalize to a generic alignment trait.typicprovidesAlignOf<T>which is an alias to<T as Layout>::Alignwhere theAlignassociated type ofLayoutis antypenum::marker_traits::Unsigned.bytemuckdoes not have an equivalent to this.
Metadata
Metadata
Assignees
Labels
new traitProposal for a new trait to be addedProposal for a new trait to be added