Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Foo {
- fn get_int(&self) -> usize;
- }
- struct Bar {}
- impl Foo for Bar {
- fn get_int(&self) -> usize { 0 }
- }
- fn do_something(_f: Box<dyn Foo>) {
- println!("hello");
- }
- fn main() {
- let x = Box::new(Bar {});
- do_something(x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement