generic/src/instances.rs

21 lines
502 B
Rust

use crate::generic::{Field, Generic, Sum};
impl<A, B> Generic for (A, B) {
type Representation = Sum<Field<A>, Field<B>>;
fn generalize(self) -> Self::Representation {
let (l, r) = self;
Sum {
left: Field { value: l },
right: Field { value: r }
}
}
fn specialize(rep: Self::Representation) -> Self {
let Sum {
left: Field { value: a },
right: Field { value: b },
} = rep;
(a, b)
}
}