Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::sync::Arc;
- fn main() {
- let mut v: Vec<Arc<dyn Human>> = Vec::new();
- let me = Taiwanese::new();
- // works with a temporarary variable.
- let me_2 = Arc::clone(&me);
- v.push(me_2);
- v.push(Arc::clone(&me)); // type mismatch without temporary variable, why?
- v.push(me);
- }
- trait Human {}
- struct Taiwanese {}
- impl Taiwanese {
- fn new() -> Arc<Taiwanese> {
- Arc::new(Taiwanese {})
- }
- }
- impl Human for Taiwanese {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement