我遇到了一大段代码的问题,但我看不出问题出在哪里
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