A ~ pointer can still be returned from a function without being deallocated, and the contained data doesn't have to be copied (unlike data on the stack).
fn make_string() -> ~str {
return ~"foo";
}
fn main() {
let string: ~str = make_string();
io::println(string);
} // deallocated here