//resolved by imp Deref to your customized smartpoiner
use std::ops::Deref;
impl<T> Deref for MyBox<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.0
}
}
//The other e.g
//Resolved by added match x.as_mut()
fn main() {
let mut x = Some(2);
match x{
Some(v) => *v = 42,
None => {},
}
assert_eq!(x, Some(42));
}
//e.g
let y = 0u32;
println!("{}",*y); // rise error
//to resolve it
let y = 0u32;
let x = &y;
// So here, `x` is a `&u32`, so we can dereference it:
println!("{}",*x);