Skip to content

Commit 6c3e78c

Browse files
committed
---
yaml --- r: 89216 b: refs/heads/snap-stage3 c: b3b49d9 h: refs/heads/master v: v3
1 parent a747265 commit 6c3e78c

File tree

4 files changed

+42
-29
lines changed

4 files changed

+42
-29
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: deeca5d586bfaa4aa60246f671a8d611d38f6248
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 86835c95f4c6f4753f139b096f9949a742c0ab51
4+
refs/heads/snap-stage3: b3b49d9873afaa600ba9dc00566dba73c3eae195
55
refs/heads/try: b160761e35efcd1207112b3b782c06633cf441a8
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/doc/rust.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3806,25 +3806,6 @@ As a convenience, the logging spec can also be set to a special pseudo-crate,
38063806
`::help`. In this case, when the application starts, the runtime will
38073807
simply output a list of loaded modules containing log expressions, then exit.
38083808

3809-
The Rust runtime itself generates logging information. The runtime's logs are
3810-
generated for a number of artificial modules in the `::rt` pseudo-crate,
3811-
and can be enabled just like the logs for any standard module. The full list
3812-
of runtime logging modules follows.
3813-
3814-
* `::rt::mem` Memory management
3815-
* `::rt::comm` Messaging and task communication
3816-
* `::rt::task` Task management
3817-
* `::rt::dom` Task scheduling
3818-
* `::rt::trace` Unused
3819-
* `::rt::cache` Type descriptor cache
3820-
* `::rt::upcall` Compiler-generated runtime calls
3821-
* `::rt::timer` The scheduler timer
3822-
* `::rt::gc` Garbage collection
3823-
* `::rt::stdlib` Functions used directly by the standard library
3824-
* `::rt::kern` The runtime kernel
3825-
* `::rt::backtrace` Log a backtrace on task failure
3826-
* `::rt::callback` Unused
3827-
38283809
#### Logging Expressions
38293810

38303811
Rust provides several macros to log information. Here's a simple Rust program

branches/snap-stage3/src/librustc/middle/typeck/coherence.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,9 @@ impl CoherenceChecker {
426426

427427
pub fn check_implementation_coherence(&self) {
428428
let trait_impls = self.crate_context.tcx.trait_impls.borrow();
429-
trait_impls.get().each_key(|&trait_id| {
429+
for &trait_id in trait_impls.get().keys() {
430430
self.check_implementation_coherence_of(trait_id);
431-
true
432-
});
431+
}
433432
}
434433

435434
pub fn check_implementation_coherence_of(&self, trait_def_id: DefId) {

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

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ use clone::Clone;
5757
use cmp::{Eq, Equiv};
5858
use default::Default;
5959
use hash::Hash;
60+
use iter;
6061
use iter::{Iterator, FromIterator, Extendable};
6162
use iter::{FilterMap, Chain, Repeat, Zip};
6263
use num;
@@ -525,14 +526,16 @@ impl<K: Hash + Eq, V> HashMap<K, V> {
525526
}
526527
}
527528

528-
/// Visit all keys
529-
pub fn each_key(&self, blk: |k: &K| -> bool) -> bool {
530-
self.iter().advance(|(k, _)| blk(k))
529+
/// An iterator visiting all keys in arbitrary order.
530+
/// Iterator element type is &'a K.
531+
pub fn keys<'a>(&'a self) -> HashMapKeyIterator<'a, K, V> {
532+
self.iter().map(|(k, _v)| k)
531533
}
532534

533-
/// Visit all values
534-
pub fn each_value<'a>(&'a self, blk: |v: &'a V| -> bool) -> bool {
535-
self.iter().advance(|(_, v)| blk(v))
535+
/// An iterator visiting all values in arbitrary order.
536+
/// Iterator element type is &'a V.
537+
pub fn values<'a>(&'a self) -> HashMapValueIterator<'a, K, V> {
538+
self.iter().map(|(_k, v)| v)
536539
}
537540

538541
/// An iterator visiting all key-value pairs in arbitrary order.
@@ -609,6 +612,14 @@ pub struct HashMapMoveIterator<K, V> {
609612
priv iter: vec::MoveIterator<Option<Bucket<K, V>>>,
610613
}
611614

615+
/// HashMap keys iterator
616+
pub type HashMapKeyIterator<'a, K, V> =
617+
iter::Map<'static, (&'a K, &'a V), &'a K, HashMapIterator<'a, K, V>>;
618+
619+
/// HashMap values iterator
620+
pub type HashMapValueIterator<'a, K, V> =
621+
iter::Map<'static, (&'a K, &'a V), &'a V, HashMapIterator<'a, K, V>>;
622+
612623
/// HashSet iterator
613624
#[deriving(Clone)]
614625
pub struct HashSetIterator<'a, K> {
@@ -1015,6 +1026,28 @@ mod test_map {
10151026
assert_eq!(observed, 0xFFFF_FFFF);
10161027
}
10171028

1029+
#[test]
1030+
fn test_keys() {
1031+
let vec = ~[(1, 'a'), (2, 'b'), (3, 'c')];
1032+
let map = vec.move_iter().collect::<HashMap<int, char>>();
1033+
let keys = map.keys().map(|&k| k).collect::<~[int]>();
1034+
assert_eq!(keys.len(), 3);
1035+
assert!(keys.contains(&1));
1036+
assert!(keys.contains(&2));
1037+
assert!(keys.contains(&3));
1038+
}
1039+
1040+
#[test]
1041+
fn test_values() {
1042+
let vec = ~[(1, 'a'), (2, 'b'), (3, 'c')];
1043+
let map = vec.move_iter().collect::<HashMap<int, char>>();
1044+
let values = map.values().map(|&v| v).collect::<~[char]>();
1045+
assert_eq!(values.len(), 3);
1046+
assert!(values.contains(&'a'));
1047+
assert!(values.contains(&'b'));
1048+
assert!(values.contains(&'c'));
1049+
}
1050+
10181051
#[test]
10191052
fn test_find() {
10201053
let mut m = HashMap::new();

0 commit comments

Comments
 (0)