我正在玩这个玩具结构:
pub struct Community {
pub community_contents: RwLock<CommunityContents>,
}
pub struct CommunityContents {
pub friends: RefCell<HashMap<FriendID, FriendData>>,
pub index: RefCell<HashMap<u64, BTreeMap<FriendID, FriendData>>>,
pub authenticated: bool,
pub age: u64,
pub height: u64,
}
我的理论是在 of 周围有一个,Arc
然后我可以有多个写入器,这些写入器可以独立/同时修改via的和字段。RwLock
Community
RwLock
friends
index
CommunityContents
Rc<RefCell
这甚至可能吗?RwLock
无论如何,一次只允许一个以上的作家 - 在这种情况下,我应该删除并RefCells
简化整个结构?