This example compiles and returns the "expected" output. But is this not a dangling pointer scenario? If so, how come the rust compiler allows this?
use serde_json::{Value, json};
use std::io::Result;
fn main(){
println!("{:#?}", test_json_lifetime());
}
fn test_json_lifetime() -> Result<(Value)> {
let j = json!({ "name" : "test" });
Ok(j)
}