我正在学习Rust,并尝试使用RefCell。我有给定的代码,
struct MyStruct {
data: RefCell<Vec<i32>>
}
impl MyStruct {
fn get_value(&self, index: usize) -> Option<&i32> {
self.data.borrow().get(index)
}
}
编译器不喜欢它
cannot return value referencing temporary value
returns a value referencing data owned by the current function
如何返回值?