Created
November 15, 2012 21:28
-
-
Save bstrie/4081403 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| impl<T: Copy Add<T,T>> Option<T> : Add<Option<T>, Option<T>> { | |
| #[inline(always)] | |
| pure fn add(other: &Option<T>) -> Option<T> { | |
| match (self, *other) { | |
| (None, None) => None, | |
| (_, None) => self, | |
| (None, _) => *other, | |
| (Some(ref v1), Some(ref v2)) => Some(*v1 + *v2) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment