Skip to content

Commit 3be99a2

Browse files
committed
---
yaml --- r: 42495 b: refs/heads/try c: 13d07ad h: refs/heads/master i: 42493: 0963d56 42491: 901e1ac 42487: 75b0f36 42479: 25bbdb2 42463: dca9d33 42431: 05b16cd 42367: 5530c1c 42239: 3a72b48 41983: 3f927ed v: v3
1 parent 07895c8 commit 3be99a2

File tree

5 files changed

+43
-21
lines changed

5 files changed

+43
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 19dfec2aaf746535de1521f68421f9980dbf25de
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
5-
refs/heads/try: 9788c41ce775c74613fe244d529da56285a3e6b9
5+
refs/heads/try: 13d07ad0a623a8ceaaee4c5af20de1d1d8afddf7
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278

branches/try/src/libcore/container.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
//! Container traits
12+
13+
pub trait Set<T> {
14+
/// Return true if the set contains a value
15+
pure fn contains(&self, value: &T) -> bool;
16+
17+
/// Add a value to the set. Return true if the value was not already
18+
/// present in the set.
19+
fn insert(&mut self, value: T) -> bool;
20+
21+
/// Remove a value from the set. Return true if the value was
22+
/// present in the set.
23+
fn remove(&mut self, value: &T) -> bool;
24+
}

branches/try/src/libcore/core.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ pub mod to_bytes;
122122
pub mod clone;
123123
pub mod io;
124124
pub mod hash;
125+
pub mod container;
125126

126127

127128
/* Common data structures */

branches/try/src/libcore/repr.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,7 @@ impl ReprVisitor : TyVisitor {
286286
fn visit_f32() -> bool { self.write::<f32>() }
287287
fn visit_f64() -> bool { self.write::<f64>() }
288288

289-
fn visit_char() -> bool {
290-
do self.get::<char> |&ch| {
291-
self.writer.write_char('\'');
292-
self.writer.write_escaped_char(ch);
293-
self.writer.write_char('\'');
294-
}
295-
}
289+
fn visit_char() -> bool { self.write::<u32>() }
296290

297291
// Type no longer exists, vestigial function.
298292
fn visit_str() -> bool { fail; }

branches/try/src/libstd/treemap.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
1515
#[forbid(deprecated_mode)];
1616

17+
use core::container::Set;
1718
use core::cmp::{Eq, Ord};
1819
use core::option::{Option, Some, None};
1920
use core::prelude::*;
@@ -197,6 +198,21 @@ impl <T: Eq Ord> TreeSet<T>: Eq {
197198
pure fn ne(&self, other: &TreeSet<T>) -> bool { self.map != other.map }
198199
}
199200

201+
impl <T: Ord> TreeSet<T>: Set<T> {
202+
/// Return true if the set contains a value
203+
pure fn contains(&self, value: &T) -> bool {
204+
self.map.contains_key(value)
205+
}
206+
207+
/// Add a value to the set. Return true if the value was not already
208+
/// present in the set.
209+
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
210+
211+
/// Remove a value from the set. Return true if the value was
212+
/// present in the set.
213+
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
214+
}
215+
200216
impl <T: Ord> TreeSet<T> {
201217
/// Create an empty TreeSet
202218
static pure fn new() -> TreeSet<T> { TreeSet{map: TreeMap::new()} }
@@ -215,19 +231,6 @@ impl <T: Ord> TreeSet<T> {
215231
self.map.each_key_reverse(f)
216232
}
217233

218-
/// Return true if the set contains a value
219-
pure fn contains(&self, value: &T) -> bool {
220-
self.map.contains_key(value)
221-
}
222-
223-
/// Add a value to the set. Return true if the value was not
224-
/// already present in the set.
225-
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
226-
227-
/// Remove a value from the set. Return true if the value was
228-
/// present in the set.
229-
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
230-
231234
/// Get a lazy iterator over the values in the set.
232235
/// Requires that it be frozen (immutable).
233236
pure fn iter(&self) -> TreeSetIterator/&self<T> {

0 commit comments

Comments
 (0)