如何将新值转换为可更改的结构引用中的字段?
struct A {
field: SomeType,}&mut Afield
fn foo(a: &mut A) {
let mut my_local_var = a.field;
a.field = SomeType::new();
// ...
// do things with my_local_var
// some operations may modify the NEW field's value as well.}get_and_set()
叮当猫咪
Cats萌萌
潇湘沐
随时随地看视频慕课网APP
相关分类