我遇到了大量代码的问题而我看不出问题是什么
use std::rc::Rc;
use std::cell::RefCell;
struct Order {
id: u64,
}
fn main() {
respond(
Order { id: 0 },
Rc::new(RefCell::new(|ord| {
ord;
()
})),
);
}
fn respond(order: Order, func: Rc<RefCell<FnMut(Order) -> ()>>) -> () {
let mut caller = func.borrow_mut();
caller(order);
}
编译器说:
error[E0596]: cannot borrow immutable borrowed content as mutable
--> src/main.rs:20:5
|
20 | caller(order);
| ^^^^^^ cannot borrow as mutable