Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code shared from the Rust Playground
struct S {
data: Option<String>
}
impl S {
fn data(&self) -> String {
if let Some(ref data) = self.data {
data.clone()
} else {
panic!()
}
}
}
fn main() {
let s = S{ data: Some(String::from("foobar")) };
dbg!(s.data());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.