Skip to content

Instantly share code, notes, and snippets.

@Kimundi
Last active January 2, 2016 23:29
Show Gist options
  • Save Kimundi/8376749 to your computer and use it in GitHub Desktop.
Save Kimundi/8376749 to your computer and use it in GitHub Desktop.
struct NotFancy<T> {
x: Option<T>
}
impl<T> NotFancy<T> {
fn simple0<'a>(&'a self) -> Option<&'a T> {
match *self.x {
Some(ref t) => Some(t),
None => None
}
}
fn simple1<'a>(&'a mut self) -> Option<&'a mut T> {
match *self.x {
Some(ref mut t) => Some(t),
None => None
}
}
fn simple2(self) -> Option<T> {
match self.x {
Some(t) => Some(t),
None => None
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment