Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait DoSomething {
- fn do_it() -> String {
- "hi".to_string()
- }
- fn me_do_it(&self) -> String {
- let result = <Self as DoSomething>::do_it();
- format!("{}{}", result, "deho".to_string())
- }
- }
- struct Foo;
- impl DoSomething for Foo {}
- fn main() {
- let output = Foo::do_it();
- println!("output: {}", output);
- let foo = Foo;
- let output = foo.me_do_it();
- println!("output: {}", output);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement