Skip to content

Commit e5aca1b

Browse files
committed
---
yaml --- r: 124591 b: refs/heads/auto c: ab61022 h: refs/heads/master i: 124589: 09a6c49 124587: 8d5b876 124583: e21fc7f 124575: 23d0bb2 v: v3
1 parent 6ddcec5 commit e5aca1b

File tree

103 files changed

+2849
-981
lines changed

Some content is hidden

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

103 files changed

+2849
-981
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 0c30e1faad86214e28454d223ffa040212897a1e
16+
refs/heads/auto: ab610226aa150102771b5c18b3adc335fd9374dc
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/libcollections/dlist.rs

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,23 @@ impl<T> DList<T> {
278278
/// Move the last element to the front of the list.
279279
///
280280
/// If the list is empty, do nothing.
281+
///
282+
/// # Example
283+
///
284+
/// ```rust
285+
/// use std::collections::{DList, Deque};
286+
///
287+
/// let mut dl = DList::new();
288+
/// dl.push_back(1i);
289+
/// dl.push_back(2);
290+
/// dl.push_back(3);
291+
///
292+
/// dl.rotate_forward();
293+
///
294+
/// for e in dl.iter() {
295+
/// println!("{}", e); // prints 3, then 1, then 2
296+
/// }
297+
/// ```
281298
#[inline]
282299
pub fn rotate_forward(&mut self) {
283300
self.pop_back_node().map(|tail| {
@@ -288,6 +305,23 @@ impl<T> DList<T> {
288305
/// Move the first element to the back of the list.
289306
///
290307
/// If the list is empty, do nothing.
308+
///
309+
/// # Example
310+
///
311+
/// ```rust
312+
/// use std::collections::{DList, Deque};
313+
///
314+
/// let mut dl = DList::new();
315+
/// dl.push_back(1i);
316+
/// dl.push_back(2);
317+
/// dl.push_back(3);
318+
///
319+
/// dl.rotate_backward();
320+
///
321+
/// for e in dl.iter() {
322+
/// println!("{}", e); // prints 2, then 3, then 1
323+
/// }
324+
/// ```
291325
#[inline]
292326
pub fn rotate_backward(&mut self) {
293327
self.pop_front_node().map(|head| {
@@ -298,6 +332,25 @@ impl<T> DList<T> {
298332
/// Add all elements from `other` to the end of the list
299333
///
300334
/// O(1)
335+
///
336+
/// # Example
337+
///
338+
/// ```rust
339+
/// use std::collections::{DList, Deque};
340+
///
341+
/// let mut a = DList::new();
342+
/// let mut b = DList::new();
343+
/// a.push_back(1i);
344+
/// a.push_back(2);
345+
/// b.push_back(3i);
346+
/// b.push_back(4);
347+
///
348+
/// a.append(b);
349+
///
350+
/// for e in a.iter() {
351+
/// println!("{}", e); // prints 1, then 2, then 3, then 4
352+
/// }
353+
/// ```
301354
pub fn append(&mut self, mut other: DList<T>) {
302355
match self.list_tail.resolve() {
303356
None => *self = other,
@@ -320,6 +373,25 @@ impl<T> DList<T> {
320373
/// Add all elements from `other` to the beginning of the list
321374
///
322375
/// O(1)
376+
///
377+
/// # Example
378+
///
379+
/// ```rust
380+
/// use std::collections::{DList, Deque};
381+
///
382+
/// let mut a = DList::new();
383+
/// let mut b = DList::new();
384+
/// a.push_back(1i);
385+
/// a.push_back(2);
386+
/// b.push_back(3i);
387+
/// b.push_back(4);
388+
///
389+
/// a.prepend(b);
390+
///
391+
/// for e in a.iter() {
392+
/// println!("{}", e); // prints 3, then 4, then 1, then 2
393+
/// }
394+
/// ```
323395
#[inline]
324396
pub fn prepend(&mut self, mut other: DList<T>) {
325397
mem::swap(self, &mut other);
@@ -330,6 +402,25 @@ impl<T> DList<T> {
330402
/// or at the end.
331403
///
332404
/// O(N)
405+
///
406+
/// # Example
407+
///
408+
/// ```rust
409+
/// use std::collections::{DList, Deque};
410+
///
411+
/// let mut a: DList<int> = DList::new();
412+
/// a.push_back(2i);
413+
/// a.push_back(4);
414+
/// a.push_back(7);
415+
/// a.push_back(8);
416+
///
417+
/// // insert 11 before the first odd number in the list
418+
/// a.insert_when(11, |&e, _| e % 2 == 1);
419+
///
420+
/// for e in a.iter() {
421+
/// println!("{}", e); // prints 2, then 4, then 11, then 7, then 8
422+
/// }
423+
/// ```
333424
pub fn insert_when(&mut self, elt: T, f: |&T, &T| -> bool) {
334425
{
335426
let mut it = self.mut_iter();

branches/auto/src/libcollections/str.rs

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@ impl OwnedStr for String {
808808
#[cfg(test)]
809809
mod tests {
810810
use std::iter::AdditiveIterator;
811+
use std::iter::range;
811812
use std::default::Default;
812813
use std::char::Char;
813814
use std::clone::Clone;
@@ -1610,6 +1611,30 @@ mod tests {
16101611
assert_eq!(pos, v.len());
16111612
}
16121613

1614+
#[test]
1615+
fn test_chars_decoding() {
1616+
let mut bytes = [0u8, ..4];
1617+
for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) {
1618+
let len = c.encode_utf8(bytes);
1619+
let s = ::core::str::from_utf8(bytes.slice_to(len)).unwrap();
1620+
if Some(c) != s.chars().next() {
1621+
fail!("character {:x}={} does not decode correctly", c as u32, c);
1622+
}
1623+
}
1624+
}
1625+
1626+
#[test]
1627+
fn test_chars_rev_decoding() {
1628+
let mut bytes = [0u8, ..4];
1629+
for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) {
1630+
let len = c.encode_utf8(bytes);
1631+
let s = ::core::str::from_utf8(bytes.slice_to(len)).unwrap();
1632+
if Some(c) != s.chars().rev().next() {
1633+
fail!("character {:x}={} does not decode correctly", c as u32, c);
1634+
}
1635+
}
1636+
}
1637+
16131638
#[test]
16141639
fn test_iterator_clone() {
16151640
let s = "ศไทย中华Việt Nam";
@@ -2240,16 +2265,26 @@ mod tests {
22402265
#[cfg(test)]
22412266
mod bench {
22422267
use test::Bencher;
2268+
use test::black_box;
22432269
use super::*;
2270+
use std::option::{None, Some};
22442271
use std::iter::{Iterator, DoubleEndedIterator};
22452272
use std::collections::Collection;
22462273

22472274
#[bench]
22482275
fn char_iterator(b: &mut Bencher) {
22492276
let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
2250-
let len = s.char_len();
22512277

2252-
b.iter(|| assert_eq!(s.chars().count(), len));
2278+
b.iter(|| s.chars().count());
2279+
}
2280+
2281+
#[bench]
2282+
fn char_iterator_for(b: &mut Bencher) {
2283+
let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
2284+
2285+
b.iter(|| {
2286+
for ch in s.chars() { black_box(ch) }
2287+
});
22532288
}
22542289

22552290
#[bench]
@@ -2260,17 +2295,24 @@ mod bench {
22602295
Mary had a little lamb, Little lamb
22612296
Mary had a little lamb, Little lamb
22622297
Mary had a little lamb, Little lamb";
2263-
let len = s.char_len();
22642298

2265-
b.iter(|| assert_eq!(s.chars().count(), len));
2299+
b.iter(|| s.chars().count());
22662300
}
22672301

22682302
#[bench]
22692303
fn char_iterator_rev(b: &mut Bencher) {
22702304
let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
2271-
let len = s.char_len();
22722305

2273-
b.iter(|| assert_eq!(s.chars().rev().count(), len));
2306+
b.iter(|| s.chars().rev().count());
2307+
}
2308+
2309+
#[bench]
2310+
fn char_iterator_rev_for(b: &mut Bencher) {
2311+
let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
2312+
2313+
b.iter(|| {
2314+
for ch in s.chars().rev() { black_box(ch) }
2315+
});
22742316
}
22752317

22762318
#[bench]

branches/auto/src/libcore/ops.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,19 +749,23 @@ pub trait DerefMut<Result>: Deref<Result> {
749749
#[lang="fn"]
750750
pub trait Fn<Args,Result> {
751751
/// This is called when the call operator is used.
752+
#[rust_call_abi_hack]
752753
fn call(&self, args: Args) -> Result;
753754
}
754755

755756
/// A version of the call operator that takes a mutable receiver.
756757
#[lang="fn_mut"]
757758
pub trait FnMut<Args,Result> {
758759
/// This is called when the call operator is used.
760+
#[rust_call_abi_hack]
759761
fn call_mut(&mut self, args: Args) -> Result;
760762
}
761763

762764
/// A version of the call operator that takes a by-value receiver.
763765
#[lang="fn_once"]
764766
pub trait FnOnce<Args,Result> {
765767
/// This is called when the call operator is used.
768+
#[rust_call_abi_hack]
766769
fn call_once(self, args: Args) -> Result;
767770
}
771+

branches/auto/src/libcore/prelude.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub use ops::{BitAnd, BitOr, BitXor};
3535
pub use ops::{Drop, Deref, DerefMut};
3636
pub use ops::{Shl, Shr};
3737
pub use ops::{Index, IndexMut};
38+
pub use ops::{Fn, FnMut, FnOnce};
3839
pub use option::{Option, Some, None};
3940
pub use result::{Result, Ok, Err};
4041

0 commit comments

Comments
 (0)