coremem_types: enums don't require their variant to be Copy
this is safe because the variant is necessarily not ZST. if it was ZST it could just be stored explicitly instead of folding it into the first element, and that case should still be OK.
This commit is contained in:
@@ -110,11 +110,11 @@ where
|
||||
impl<L> EnumRequirements for Enum<(), L>
|
||||
where
|
||||
L: list::Meta + Indexable<P0>,
|
||||
list::ElementAt<P0, L>: Copy + DiscriminantCodable<<<L as list::Meta>::Length as PeanoNonZero>::Prev>,
|
||||
list::ElementAt<P0, L>: DiscriminantCodable<<<L as list::Meta>::Length as PeanoNonZero>::Prev>,
|
||||
{
|
||||
type MaxDiscr = <<L as list::Meta>::Length as PeanoNonZero>::Prev;
|
||||
fn discr(&self) -> Discr<Self::MaxDiscr> {
|
||||
self.1.get().discr()
|
||||
self.1.get_ref().discr()
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -32,6 +32,7 @@ impl<H, T> Node<H, T> {
|
||||
pub trait Indexable<P: Peano> {
|
||||
type Element;
|
||||
fn get(&self) -> Self::Element where Self::Element: Copy;
|
||||
fn get_ref(&self) -> &Self::Element;
|
||||
}
|
||||
|
||||
impl<E0, T> Indexable<P0> for Node<E0, T> {
|
||||
@@ -39,6 +40,9 @@ impl<E0, T> Indexable<P0> for Node<E0, T> {
|
||||
fn get(&self) -> Self::Element where Self::Element: Copy {
|
||||
self.head
|
||||
}
|
||||
fn get_ref(&self) -> &Self::Element {
|
||||
&self.head
|
||||
}
|
||||
}
|
||||
|
||||
impl<E0, E1, T> Indexable<P1> for Node<E0, Node<E1, T>> {
|
||||
@@ -46,6 +50,9 @@ impl<E0, E1, T> Indexable<P1> for Node<E0, Node<E1, T>> {
|
||||
fn get(&self) -> Self::Element where Self::Element: Copy {
|
||||
self.tail.head
|
||||
}
|
||||
fn get_ref(&self) -> &Self::Element {
|
||||
&self.tail.head
|
||||
}
|
||||
}
|
||||
|
||||
impl<E0, E1, E2, T> Indexable<P2> for Node<E0, Node<E1, Node<E2, T>>> {
|
||||
@@ -53,6 +60,9 @@ impl<E0, E1, E2, T> Indexable<P2> for Node<E0, Node<E1, Node<E2, T>>> {
|
||||
fn get(&self) -> Self::Element where Self::Element: Copy {
|
||||
self.tail.tail.head
|
||||
}
|
||||
fn get_ref(&self) -> &Self::Element {
|
||||
&self.tail.tail.head
|
||||
}
|
||||
}
|
||||
|
||||
impl<E0, E1, E2, E3, T> Indexable<P3> for Node<E0, Node<E1, Node<E2, Node<E3, T>>>> {
|
||||
@@ -60,6 +70,9 @@ impl<E0, E1, E2, E3, T> Indexable<P3> for Node<E0, Node<E1, Node<E2, Node<E3, T>
|
||||
fn get(&self) -> Self::Element where Self::Element: Copy {
|
||||
self.tail.tail.tail.head
|
||||
}
|
||||
fn get_ref(&self) -> &Self::Element {
|
||||
&self.tail.tail.tail.head
|
||||
}
|
||||
}
|
||||
|
||||
pub trait IntoList {
|
||||
|
Reference in New Issue
Block a user