Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Surface: 'static {}
- struct Manager {
- storage: Vec<Box<Surface>>,
- }
- impl Manager {
- fn add(&mut self, surface: impl Surface) {
- self.storage.push(Box::new(surface));
- }
- }
- struct SomeOtherStruct {}
- struct Obj<'a> {
- data: &'a mut SomeOtherStruct,
- }
- impl<'a> Obj<'a> {
- fn new(some_struct: &'a mut SomeOtherStruct) -> Self {
- Obj {
- data: some_struct
- }
- }
- }
- impl<'a> Surface for Obj<'a> where 'a: 'static {}
- fn main() {
- let mut some_struct = SomeOtherStruct{};
- let mut manager = Manager { storage: Vec::new() };
- let obj = Obj::new(&mut some_struct);
- manager.add(obj);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement