I don't think so, because the fact that the particular instance of T implements
the Deref trait cannot have any effect on the decorator code, since it's not in
the bounds for T.
What instead would work is to change the language so that if type Type
implements Trait and all Trait methods take &self or &mut self (as opposed to
by value self or ~self), then an implementation of Trait for &'a mut Type is
automatically generated (with the obvious implementation).
Likewise if all Trait methods take &self, then an implementation of Trait for
&'a Type is also automatically generated.
Then what you want to do will just work without the need of any wrapper or
special syntax.
One could then, as an additional step, automatically generate an implementation
of Trait for MutDeref<Type> if Trait is implemented by &mut Type (possibly due
to the above technique), but this would not be required for the example.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev