When drop is called for a mut String variable?

       fn foo() {
             let mut s = String::from("a string on the heap");
             s = String::("another string on the heap"); // new allocation 
       } // when code reaches here drop is called

When code reaches } drop is called, deallocation occurs for the string “another string on the heap”. The first string how is it deallocated???


At the time where s is assigned. The old value is dropped before the new one takes its place.


Thanks a lot! This is reasonable.