use core::cell::Cell; use selfref::Holder; use selfref::opaque; mod bad { use super::*; use std::rc::Rc; struct Foo<'a> { x: String, y: Rc>, } struct FooOpaque; opaque! { impl Opaque for FooOpaque { type Kind<'a> = Foo<'a>; } } pub fn test() { let rc = Rc::new(Cell::new("")); let rc_clone = rc.clone(); let x = Holder::<'_, FooOpaque>::new_with(move |builder| { builder.build(Foo { x: "Hello".to_owned(), y: rc_clone, }); }); let x = Box::pin(x); x.as_ref().operate_in(|foo| { let foo = foo.get_ref(); foo.y.set(&foo.x); }); dbg!(&rc); drop(x); dbg!(&rc); } } fn main() { bad::test(); }