Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::rc::{Rc, Weak};
- struct Container {
- pub item: Rc<Item>,
- pub trait_ref: Weak<Box<Trait>>,
- }
- pub struct Item;
- pub trait Trait {}
- impl Trait for Item{}
- fn main() {
- let item = Rc::new(Item);
- let trait_ref: Weak<Box<Trait>> = Rc::downgrade(&item);
- let _container = Container {
- item,
- trait_ref
- };
- }
Add Comment
Please, Sign In to add comment