Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Diffable<'a> {
- type D: 'a;
- fn diff(&'a self) -> Self::D;
- }
- struct Edit<'a, T> {
- marker: std::marker::PhantomData<&'a T>,
- }
- impl<'a, T> Edit<'a, T> {
- fn new(value: &'a T) -> Self {
- Self {
- marker: std::marker::PhantomData,
- }
- }
- }
- //#[derive(Diffus)]
- struct Foo {
- x: String,
- y: i32,
- }
- // Generated by derive(Diffus)
- struct EditedFoo<'a> {
- x: Edit<'a, String>,
- y: Edit<'a, i32>,
- }
- // Generated by derive(Diffus)
- impl<'a> Diffable<'a> for Foo {
- type D = EditedFoo<'a>;
- fn diff(&'a self) -> Self::D {
- EditedFoo {
- x: Edit::new(&self.x),
- y: Edit::new(&self.y),
- }
- }
- }
- fn main() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement