use pure_ref::Pure; #[derive(Clone)] struct Foo<'p> { #[allow(dead_code)] bar: Pure<'p, i32>, // A reference to bar pub baz: &'p i32, } impl<'p> Foo<'p> { pub fn new(val: i32) -> Self { let mut pure = Pure::new(val); let borrow = pure.borrow(); Self { bar: pure, baz: borrow, } } } #[test] pub fn test() { let foo = Foo::new(10); assert_eq!(*foo.baz, 10); }