This is possible because the function always returns the same string.
Note that the returned string should remain unchanged throughout the program
Defer borrow-checking to runtime by using garbage collection
For example, we can use a [reference-counted pointer](Rc, the Reference Counted Smart Pointer)
use std::rc::Rc;
fn return_a_string() -> Rc<String> {
let s = Rc::newfrom("Hello world");
Rc::clone(&s)
}
In short, Rc::clone only clones the pointer to s. At runtime, the Rc checks when the last Rc pointing to the data has been dropped. Only then does it deallocates the data.
Caller provides a slot for returning the string
Create a dummy argument, into which the answer is written