Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::string::ToString;
- trait Foo: ToString {}
- struct Bar {}
- impl ToString for Bar {
- fn to_string(&self) -> String {
- String::from("Bar")
- }
- }
- impl Foo for Bar {}
- struct Baz {}
- impl ToString for Baz {
- fn to_string(&self) -> String {
- String::from("Baz")
- }
- }
- impl Foo for Baz {}
- fn main() {
- let b1: &Foo = &Bar {};
- let b2: &Foo = &Baz {};
- let _v: Vec<&Foo> = vec!(b1, b2);
- }
Add Comment
Please, Sign In to add comment