Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Moo {
- fn moo(&self) -> String;
- }
- trait SuperMoo: Moo {
- fn supermoo(&self) {
- println!("Super! {}", self.moo());
- }
- fn supercow() {
- println!("SuperCow!");
- }
- }
- struct Cow {
- }
- impl Moo for Cow {
- fn moo(&self) -> String {
- "MOOOOO".to_string()
- }
- }
- fn main() {
- let c = Cow{};
- let m = Box::new(c) as Box<Moo>;
- <c as SuperMoo>::supercow();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement