pub trait FiniteNimberBase:
BitXor<Output = Self::Owned> + Eq + Debug + Sized
{
+ type Cheap<'a>: FiniteNimberBase where Self: 'a;
type Owned: FiniteNimberBase + Clone;
+ fn to_cheap<'a>(&'a self) -> Self::Cheap<'a>;
fn to_owned(self) -> Self::Owned;
}
impl FiniteNimberBase for u64 {
+ type Cheap<'a> = Self where Self: 'a;
type Owned = Self;
+ fn to_cheap<'a>(&'a self) -> Self::Cheap<'a> {
+ *self
+ }
+
fn to_owned(self) -> Self::Owned {
self
}
}
impl FiniteNimberBase for IntVector {
- type Owned = Self;
+ type Cheap<'a> = IntSlice<'a> where Self: 'a;
+ type Owned = IntVector;
+
+ fn to_cheap<'a>(&'a self) -> Self::Cheap<'a> {
+ IntSlice(&self.0)
+ }
fn to_owned(self) -> Self::Owned {
self
}
}
-impl FiniteNimberBase for IntSlice<'_> {
+impl<'a> FiniteNimberBase for IntSlice<'a> {
+ type Cheap<'b> = IntSlice<'b> where Self: 'b;
type Owned = IntVector;
+ fn to_cheap<'b>(&'b self) -> Self::Cheap<'b> {
+ IntSlice(self.0)
+ }
+
fn to_owned(self) -> Self::Owned {
IntVector(self.0.into())
}