Hard
Box::leak and the 'static lifetime bound
This function takes a heap-allocated String and hands back a &'static str pointing at it. Does this compile, and is the returned reference genuinely valid for 'static?
main.rs
fn make_static(s: String) -> &'static str {
Box::leak(s.into_boxed_str())
}
fn main() {
let owned = String::from("hello from the heap");
let leaked: &'static str = make_static(owned);
println!("{}", leaked);
}4 of 53 in Rust