How do I return a reference to something inside a RefCell without breaking encapsulation?

Instead of creating a brand new type, you can use Ref::map (since Rust 1.8). This has the same result as Levans’ existing answer: use std::cell::Ref; impl Foo { pub fn get_items(&self) -> Ref<‘_, Vec<i32>> { Ref::map(self.interior.borrow(), |mi| &mi.vec) } } You can also use new features like impl Trait to hide the Ref from the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)