Skip to content

Commit c2087b6

Browse files
committed
---
yaml --- r: 161275 b: refs/heads/snap-stage3 c: f6cb58c h: refs/heads/master i: 161273: 721401c 161271: c29970d v: v3
1 parent 00714cc commit c2087b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2172
-1257
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: 4eb72d268f337a8f117c86a2ac1b98336cab9e9d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: f1f6c1286f24f6f762a9b195ac678b55d20c9a9b
4+
refs/heads/snap-stage3: f6cb58caeedf509cc80dd376bbb2541a0446046b
55
refs/heads/try: 0f0d21c1eb5c7be04d323e0b06faf252ad790af6
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/etc/emacs/rust-mode.el

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
(modify-syntax-entry ?\" "\"" table)
3232
(modify-syntax-entry ?\\ "\\" table)
3333

34-
;; _ is a word-char
35-
(modify-syntax-entry ?_ "w" table)
36-
3734
;; Comments
3835
(modify-syntax-entry ?/ ". 124b" table)
3936
(modify-syntax-entry ?* ". 23" table)
@@ -397,7 +394,7 @@ This is written mainly to be used as `beginning-of-defun-function' for Rust.
397394
Don't move to the beginning of the line. `beginning-of-defun',
398395
which calls this, does that afterwards."
399396
(interactive "p")
400-
(re-search-backward (concat "^\\(" rust-top-item-beg-re "\\)\\b")
397+
(re-search-backward (concat "^\\(" rust-top-item-beg-re "\\)\\_>")
401398
nil 'move (or arg 1)))
402399

403400
(defun rust-end-of-defun ()

branches/snap-stage3/src/libcollections/binary_heap.rs

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ use core::mem::{zeroed, replace, swap};
160160
use core::ptr;
161161

162162
use slice;
163-
use vec::Vec;
164-
165-
// FIXME(conventions): implement into_iter
163+
use vec::{mod, Vec};
166164

167165
/// A priority queue implemented with a binary heap.
168166
///
@@ -243,6 +241,27 @@ impl<T: Ord> BinaryHeap<T> {
243241
Items { iter: self.data.iter() }
244242
}
245243

244+
/// Creates a consuming iterator, that is, one that moves each value out of
245+
/// the binary heap in arbitrary order. The binary heap cannot be used
246+
/// after calling this.
247+
///
248+
/// # Example
249+
///
250+
/// ```
251+
/// use std::collections::BinaryHeap;
252+
/// let pq = BinaryHeap::from_vec(vec![1i, 2, 3, 4]);
253+
///
254+
/// // Print 1, 2, 3, 4 in arbitrary order
255+
/// for x in pq.into_iter() {
256+
/// // x has type int, not &int
257+
/// println!("{}", x);
258+
/// }
259+
/// ```
260+
#[unstable = "matches collection reform specification, waiting for dust to settle"]
261+
pub fn into_iter(self) -> MoveItems<T> {
262+
MoveItems { iter: self.data.into_iter() }
263+
}
264+
246265
/// Returns the greatest item in a queue, or `None` if it is empty.
247266
///
248267
/// # Example
@@ -548,6 +567,26 @@ impl<'a, T> Iterator<&'a T> for Items<'a, T> {
548567
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
549568
}
550569

570+
/// An iterator that moves out of a `BinaryHeap`.
571+
pub struct MoveItems<T> {
572+
iter: vec::MoveItems<T>,
573+
}
574+
575+
impl<T> Iterator<T> for MoveItems<T> {
576+
#[inline]
577+
fn next(&mut self) -> Option<T> { self.iter.next() }
578+
579+
#[inline]
580+
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
581+
}
582+
583+
impl<T> DoubleEndedIterator<T> for MoveItems<T> {
584+
#[inline]
585+
fn next_back(&mut self) -> Option<T> { self.iter.next_back() }
586+
}
587+
588+
impl<T> ExactSize<T> for MoveItems<T> {}
589+
551590
impl<T: Ord> FromIterator<T> for BinaryHeap<T> {
552591
fn from_iter<Iter: Iterator<T>>(mut iter: Iter) -> BinaryHeap<T> {
553592
let vec: Vec<T> = iter.collect();
@@ -586,6 +625,43 @@ mod tests {
586625
}
587626
}
588627

628+
#[test]
629+
fn test_move_iter() {
630+
let data = vec!(5i, 9, 3);
631+
let iterout = vec!(9i, 5, 3);
632+
let pq = BinaryHeap::from_vec(data);
633+
634+
let v: Vec<int> = pq.into_iter().collect();
635+
assert_eq!(v, iterout);
636+
}
637+
638+
#[test]
639+
fn test_move_iter_size_hint() {
640+
let data = vec!(5i, 9);
641+
let pq = BinaryHeap::from_vec(data);
642+
643+
let mut it = pq.into_iter();
644+
645+
assert_eq!(it.size_hint(), (2, Some(2)));
646+
assert_eq!(it.next(), Some(9i));
647+
648+
assert_eq!(it.size_hint(), (1, Some(1)));
649+
assert_eq!(it.next(), Some(5i));
650+
651+
assert_eq!(it.size_hint(), (0, Some(0)));
652+
assert_eq!(it.next(), None);
653+
}
654+
655+
#[test]
656+
fn test_move_iter_reverse() {
657+
let data = vec!(5i, 9, 3);
658+
let iterout = vec!(3i, 5, 9);
659+
let pq = BinaryHeap::from_vec(data);
660+
661+
let v: Vec<int> = pq.into_iter().rev().collect();
662+
assert_eq!(v, iterout);
663+
}
664+
589665
#[test]
590666
fn test_top_and_pop() {
591667
let data = vec!(2u, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1);

branches/snap-stage3/src/libcollections/str.rs

Lines changed: 75 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl<S: Str> StrVector for [S] {
163163
}
164164
}
165165

166-
impl<S: Str> StrVector for Vec<S> {
166+
impl<S: Str, T: AsSlice<S>> StrVector for T {
167167
#[inline]
168168
fn concat(&self) -> String {
169169
self.as_slice().concat()
@@ -929,54 +929,93 @@ mod tests {
929929
assert_eq!("ะเทศไท", "ประเทศไทย中华Việt Nam".slice_chars(2, 8));
930930
}
931931

932-
#[test]
933-
fn test_concat() {
934-
fn t(v: &[String], s: &str) {
935-
assert_eq!(v.concat().as_slice(), s);
932+
struct S {
933+
x: [String, .. 2]
934+
}
935+
936+
impl AsSlice<String> for S {
937+
fn as_slice<'a> (&'a self) -> &'a [String] {
938+
&self.x
939+
}
940+
}
941+
942+
fn s(x: &str) -> String { x.into_string() }
943+
944+
macro_rules! test_concat {
945+
($expected: expr, $string: expr) => {
946+
{
947+
let s = $string.concat();
948+
assert_eq!($expected, s.as_slice());
949+
}
936950
}
937-
t(&[String::from_str("you"), String::from_str("know"),
938-
String::from_str("I'm"),
939-
String::from_str("no"), String::from_str("good")],
940-
"youknowI'mnogood");
941-
let v: &[String] = &[];
942-
t(v, "");
943-
t(&[String::from_str("hi")], "hi");
944951
}
945952

946953
#[test]
947-
fn test_connect() {
948-
fn t(v: &[String], sep: &str, s: &str) {
949-
assert_eq!(v.connect(sep).as_slice(), s);
954+
fn test_concat_for_different_types() {
955+
test_concat!("ab", ["a", "b"]);
956+
test_concat!("ab", [s("a"), s("b")]);
957+
test_concat!("ab", vec!["a", "b"]);
958+
test_concat!("ab", vec!["a", "b"].as_slice());
959+
test_concat!("ab", vec![s("a"), s("b")]);
960+
961+
let mut v0 = ["a", "b"];
962+
let mut v1 = [s("a"), s("b")];
963+
unsafe {
964+
use std::c_vec::CVec;
965+
966+
test_concat!("ab", CVec::new(v0.as_mut_ptr(), v0.len()));
967+
test_concat!("ab", CVec::new(v1.as_mut_ptr(), v1.len()));
950968
}
951-
t(&[String::from_str("you"), String::from_str("know"),
952-
String::from_str("I'm"),
953-
String::from_str("no"), String::from_str("good")],
954-
" ", "you know I'm no good");
955-
let v: &[String] = &[];
956-
t(v, " ", "");
957-
t(&[String::from_str("hi")], " ", "hi");
969+
970+
test_concat!("ab", S { x: [s("a"), s("b")] });
958971
}
959972

960973
#[test]
961-
fn test_concat_slices() {
962-
fn t(v: &[&str], s: &str) {
963-
assert_eq!(v.concat().as_slice(), s);
974+
fn test_concat_for_different_lengths() {
975+
let empty: &[&str] = &[];
976+
test_concat!("", empty);
977+
test_concat!("a", ["a"]);
978+
test_concat!("ab", ["a", "b"]);
979+
test_concat!("abc", ["", "a", "bc"]);
980+
}
981+
982+
macro_rules! test_connect {
983+
($expected: expr, $string: expr, $delim: expr) => {
984+
{
985+
let s = $string.connect($delim);
986+
assert_eq!($expected, s.as_slice());
987+
}
964988
}
965-
t(&["you", "know", "I'm", "no", "good"], "youknowI'mnogood");
966-
let v: &[&str] = &[];
967-
t(v, "");
968-
t(&["hi"], "hi");
969989
}
970990

971991
#[test]
972-
fn test_connect_slices() {
973-
fn t(v: &[&str], sep: &str, s: &str) {
974-
assert_eq!(v.connect(sep).as_slice(), s);
992+
fn test_connect_for_different_types() {
993+
test_connect!("a-b", ["a", "b"], "-");
994+
let hyphen = "-".into_string();
995+
test_connect!("a-b", [s("a"), s("b")], hyphen.as_slice());
996+
test_connect!("a-b", vec!["a", "b"], hyphen.as_slice());
997+
test_connect!("a-b", vec!["a", "b"].as_slice(), "-");
998+
test_connect!("a-b", vec![s("a"), s("b")], "-");
999+
1000+
let mut v0 = ["a", "b"];
1001+
let mut v1 = [s("a"), s("b")];
1002+
unsafe {
1003+
use std::c_vec::CVec;
1004+
1005+
test_connect!("a-b", CVec::new(v0.as_mut_ptr(), v0.len()), "-");
1006+
test_connect!("a-b", CVec::new(v1.as_mut_ptr(), v1.len()), hyphen.as_slice());
9751007
}
976-
t(&["you", "know", "I'm", "no", "good"],
977-
" ", "you know I'm no good");
978-
t(&[], " ", "");
979-
t(&["hi"], " ", "hi");
1008+
1009+
test_connect!("a-b", S { x: [s("a"), s("b")] }, "-");
1010+
}
1011+
1012+
#[test]
1013+
fn test_connect_for_different_lengths() {
1014+
let empty: &[&str] = &[];
1015+
test_connect!("", empty, "-");
1016+
test_connect!("a", ["a"], "-");
1017+
test_connect!("a-b", ["a", "b"], "-");
1018+
test_connect!("-a-bc", ["", "a", "bc"], "-");
9801019
}
9811020

9821021
#[test]

branches/snap-stage3/src/libcore/any.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ use intrinsics::TypeId;
8888
#[stable]
8989
pub trait Any: 'static {
9090
/// Get the `TypeId` of `self`
91-
#[stable]
91+
#[experimental = "this method will likely be replaced by an associated static"]
9292
fn get_type_id(&self) -> TypeId;
9393
}
9494

0 commit comments

Comments
 (0)