我正在尝试使用内部可变模式来共享可变引用。
但是,当我尝试使用与其共享的结构的引用时,程序会对错误感到恐慌:
thread 'main' panicked at 'already borrowed: BorrowMutError'
以下是代码:
use std::rc::Rc;
use std::cell::RefCell;
fn main() {
let game = Game::init();
game.start();
}
struct Game {
ecs: Rc<RefCell<Ecs>>,
}
i