Skip to content

Instantly share code, notes, and snippets.

@daboross
Created November 28, 2014 02:13
Show Gist options
  • Save daboross/e9a25e460043f5965897 to your computer and use it in GitHub Desktop.
Save daboross/e9a25e460043f5965897 to your computer and use it in GitHub Desktop.
struct Client {
option: Option<String>,
}
fn main() {
let mut client = Client {
option: Some("address".into_string())
};
let address = match client.option {
Some(v) => {
client.option = None;
v
},
None => return
};
println!("Cloning")
address.clone();
}

Should rust be letting me do this?

$ cargo run
   Compiling test-irc v0.0.1 (file:///home/daboross/Projects/Rust/Learn/test-irc)
     Running `target/test-irc`
Cloning
An unknown error occurred

To learn more, run the command again with --verbose.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment