Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait TraitA { type Item: ?Sized; }
- trait TraitB<T> {
- fn hello(&self);
- }
- impl<X: TraitA> TraitB<X> for X::Item {
- fn hello(&self) {
- println!("Hello for X::Item");
- }
- }
- impl TraitB<()> for () {
- fn hello(&self) {
- println!("Hello for ()");
- }
- }
- impl TraitA for () {
- type Item = dyn TraitB<()>;
- }
- fn call_hello<T: ?Sized + TraitB<()>>(t: &T) {
- t.hello();
- }
- fn main() {
- call_hello::<()>(&());
- call_hello::<dyn TraitB<()>>(&() as &dyn TraitB<()>);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement