Conn {
10 | | connection: &Connection::open(db_name).expect("can't open sqlite db"),
| | -------------------------------------------------------- temporary value created here
11 | | }
| |_________^ returns a value referencing data owned by the current function
"Temporary" means something is about to be destroyed. When is it destroyed? Well, right before new returns. new shouldn't return something that was already destroyed before new returned.
Because when you have a reference in a struct, that means your struct doesn't own that value. Something else owns it, and your struct can't outlive the owner.
Well if you want to take ownership, that is the way. If you want it to be a reference, then you can do like below, but then the caller has to create the connection, and the caller owns the connection, and your struct will not be able to outlive the connection that it has a reference to.