I wrote this example (not working):
use std::sync::Mutex;
use std::ops::Deref;
pub struct DBAndCFs {
db: i32,
cfs: Vec<i32>,
}
fn main() {
let x: Mutex<Option<DBAndCFs>> = Mutex::new(Some(DBAndCFs{ db: 0, cfs: Vec::new() } ));
let DBAndCFs { ref db, ref cfs } = x.lock().unwrap().deref();
}
I have been following the docs but I am still unable to assign the db
and cfs
fields to the variables on the left.