Hi everyone!. I newbie to rust. I want to create a DatabaseConfig struct from the environment variable.
I think properties of the struct never change I choose &str over String.
But I have trouble with lifetime, I try to clone but it doesn't work.
I don't know have appropriate way to construct my struct, please give me suggestions
Cloning a reference doesn't do anything; a reference is just a compile-time checked pointer, so clonig it is a trivial bitwise copy, and it doesn't result in a clone of the underlying data. (Even without considering this: you can't change the type of a value by cloning it, since
Self, ie. the identical type.)
You should probably put a
String in your struct instead.
Awesome, Thank you for your response.