Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Bar {
- fn required(&self);
- fn provided(&self) {
- println!("I'm a boring default...");
- }
- }
- impl Bar for u32 {
- fn required(&self) {
- println!("u32 yeah yeah");
- }
- fn provided(&self) {
- println!("I'm a uuuuuu32!!");
- }
- }
- // The impl would be generated
- impl<T: Bar> Bar for Box<T> {
- fn required(&self) {
- (**self).required()
- }
- // Remove this to see difference
- fn provided(&self) {
- (**self).provided()
- }
- }
- fn main() {
- Bar::provided(&0);
- Bar::provided(&Box::new(0));
- }
Add Comment
Please, Sign In to add comment