fn testing(myptr :&mut Box<i32>) {
println!("Fn is called: {}",myptr);
*myptr=Box::new(300);
println!("Inside: {}",myptr);
*myptr=Box::new(0);
println!("Inside: {}",myptr);
drop(myptr);
}
fn main() {
let mut myptr = Box::new(100);
println!("Before Func: {}",myptr);
testing(&mut myptr);
println!("From Main: {}",myptr);
}
output
Before Func: 100
Fn is called: 100
Inside: 300
Inside: 0
From Main: 0
since i have invoked drop function i am expecting the value shouldn't be accessible even from main function but thats not happing. not able to understand why. Need help in understanding who is owning ownership and why drop function is not working.