// This function takes ownership of the heap allocated memory fn destroy_box(c: Box<int> ) { // Have to return it to be claimed again. println!("destroying a box that contains {}", c); // `c` will be destroyed in this scope, and the memory will be freed } fn borrow_variable<T: std::fmt::Show> (d: &T) { // Do not have to return the variable to let the caller reclaim it println!("variable, {} is borrowed!", d); } fn borrow_mut_variable(f: &mut f64) { *f = 42.0; }



References

Mutable references

Library defined pointers