Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait C {}
- impl C for A {}
- impl C for B {}
- pub struct A {}
- pub struct B {}
- fn main() {
- println!("Hello, world!");
- let x = "a";
- let s: Box<dyn C> = match x {
- "a" => Box::new(A {}),
- "b" => Box::new(B {}),
- _ => panic!()
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement