Skip to content

Commit 6ac5ffa

Browse files
committed
---
yaml --- r: 77268 b: refs/heads/snap-stage3 c: 20567a0 h: refs/heads/master v: v3
1 parent a0f73af commit 6ac5ffa

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: f1132496dddbdd88f321a7919eec3d65136b3f75
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 7841b77676662ed657da7b8911dd0989ac743ca0
4+
refs/heads/snap-stage3: 20567a0c3c306853180e428f83302add09b5cb8c
55
refs/heads/try: ebfe63cd1c0b5d23f7ea60c69b4fde2e30cfd42a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libstd/option.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ let unwrapped_msg = match msg {
4343

4444
use clone::Clone;
4545
use cmp::{Eq,Ord};
46+
use ops::Add;
4647
use util;
4748
use num::Zero;
4849
use iterator;
@@ -76,6 +77,18 @@ impl<T: Eq + Ord> Ord for Option<T> {
7677
}
7778
}
7879

80+
impl<T: Add<T, T>> Add<Option<T>, Option<T>> for Option<T> {
81+
#[inline]
82+
fn add(&self, other: &Option<T>) -> Option<T> {
83+
match (&*self, &*other) {
84+
(&None, &None) => None,
85+
(_, &None) => None,
86+
(&None, _) => None,
87+
(&Some(ref lhs), &Some(ref rhs)) => Some(*lhs + *rhs)
88+
}
89+
}
90+
}
91+
7992
// FIXME: #8242 implementing manually because deriving doesn't work for some reason
8093
impl<T: ToStr> ToStr for Option<T> {
8194
fn to_str(&self) -> ~str {

branches/snap-stage3/src/libstd/vec.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ And much, much more.
5959
#[warn(non_camel_case_types)];
6060

6161
use cast;
62-
use clone::Clone;
62+
use clone::{Clone, DeepClone};
6363
use container::{Container, Mutable};
6464
use cmp::{Eq, TotalOrd, Ordering, Less, Equal, Greater};
6565
use cmp;
@@ -2199,13 +2199,20 @@ pub mod bytes {
21992199
}
22002200
}
22012201

2202-
impl<A:Clone> Clone for ~[A] {
2202+
impl<A: Clone> Clone for ~[A] {
22032203
#[inline]
22042204
fn clone(&self) -> ~[A] {
22052205
self.iter().map(|item| item.clone()).collect()
22062206
}
22072207
}
22082208

2209+
impl<A: DeepClone> DeepClone for ~[A] {
2210+
#[inline]
2211+
fn deep_clone(&self) -> ~[A] {
2212+
self.iter().map(|item| item.deep_clone()).collect()
2213+
}
2214+
}
2215+
22092216
// This works because every lifetime is a sub-lifetime of 'static
22102217
impl<'self, A> Zero for &'self [A] {
22112218
fn zero() -> &'self [A] { &'self [] }
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub fn main() {
12+
let foo: int = 1;
13+
let bar: int = 2;
14+
let foobar = foo + bar;
15+
16+
let nope = None::<int> + None::<int>;
17+
let somefoo = Some(foo) + None::<int>;
18+
let somebar = None::<int> + Some(bar);
19+
let somefoobar = Some(foo) + Some(bar);
20+
21+
assert_eq!(nope, None::<int>);
22+
assert_eq!(somefoo, None::<int>);
23+
assert_eq!(somebar, None::<int>);
24+
assert_eq!(foobar, somefoobar.unwrap());
25+
}

0 commit comments

Comments
 (0)