I have these structures:
#[derive(Debug, RustcDecodable)]
struct Config {
ssl: Option<SslConfig>,
}
#[derive(Debug, RustcDecodable)]
struct SslConfig {
key: Option<String>,
cert: Option<String>,
}
They are populated from the file toml. It works great. Since I got Option<T>it, I need to either call unwrap()or do it match.
But if I want to do the following:
let cfg: Config = read_config();
let keypath = cfg.ssl.unwrap().key.unwrap();
let certpath = cfg.ssl.unwrap().cert.unwrap();
This will not work because it cfg.sslmoves to keypath. But why is this moving? I call unwrap()on sslto get the key (and unwrap()it). So, key.unwrap()should the result be moved?
? ( )? #[derive(Debug, RustcDecodable, Copy, Clone)], , Copy String. Copy Vec<u8> . ?