/// The default manager for handling the list of users stored locally. It also allows for user creation, and is used especially
/// for when creating a new user via the registration service
pub struct AccountManagerInner {
local_nac: NetworkAccount,
cnacs: HashMap<u64, ClientNetworkAccount>
}
pub struct AccountManager {
inner: Arc<RwLock<AccountManagerInner>>
}
impl Deref for AccountManager {
type Target = AccountManagerInner; // How about RwLockReadGuard<'a, AccountManagerInner>?
fn deref(&self) -> &Self::Target {
&*self.inner.read() // Deref happens here with the &*
// If I just return self.inner.read(), then I return a RwLockReadGuard<'a, AccountManagerInner>. But, this doesn't work because we need to pass a reference thereto. The struct gets created and then immediantly dropped, which invalidated the reference
}
}
Is returning a deref'd RwLockReadGuard<'a, AccountManagerInner> wise? Does dereffing it drop the guard? If not, then how does the program know that a borrow still exists?