Skip to content

Commit cdd0c08

Browse files
committed
---
yaml --- r: 154454 b: refs/heads/try2 c: f8a9211 h: refs/heads/master v: v3
1 parent 1eda07a commit cdd0c08

Some content is hidden

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

92 files changed

+291
-577
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 3570095e34c58d5f40a3f81f4c970975befebe54
8+
refs/heads/try2: f8a9211740561b1e177e5e36c1b1a6ce923492e8
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ for the 'std' and 'extra' libraries.
1919
To generate HTML documentation from one source file/crate, do something like:
2020

2121
~~~~
22-
rustdoc --output html-doc/ --output-format html ../src/libstd/path.rs
22+
rustdoc --output-dir html-doc/ --output-format html ../src/libstd/path.rs
2323
~~~~
2424

2525
(This, of course, requires a working build of the `rustdoc` tool.)

branches/try2/src/doc/guide.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ note: in expansion of format_args!
517517
<std macros>:1:1: 3:2 note: in expansion of println!
518518
src/hello_world.rs:4:5: 4:42 note: expansion site
519519
error: aborting due to previous error
520-
Could not compile `hello_world`.
520+
Could not execute process `rustc src/hello_world.rs --crate-type bin --out-dir /home/you/projects/hello_world/target -L /home/you/projects/hello_world/target -L /home/you/projects/hello_world/target/deps` (status=101)
521521
```
522522

523523
Rust will not let us use a value that has not been initialized. So why let us
@@ -532,7 +532,7 @@ in the middle of a string." We add a comma, and then `x`, to indicate that we
532532
want `x` to be the value we're interpolating. The comma is used to separate
533533
arguments we pass to functions and macros, if you're passing more than one.
534534

535-
When you just use the curly braces, Rust will attempt to display the
535+
When you just use the double curly braces, Rust will attempt to display the
536536
value in a meaningful way by checking out its type. If you want to specify the
537537
format in a more detailed manner, there are a [wide number of options
538538
available](/std/fmt/index.html). For now, we'll just stick to the default:
@@ -1888,8 +1888,15 @@ fn main() {
18881888

18891889
The first thing we changed was to `use std::rand`, as the docs
18901890
explained. We then added in a `let` expression to create a variable binding
1891-
named `secret_number`, and we printed out its result. Let's try to compile
1892-
this using `cargo build`:
1891+
named `secret_number`, and we printed out its result.
1892+
1893+
Also, you may wonder why we are using `%` on the result of `rand::random()`.
1894+
This operator is called 'modulo', and it returns the remainder of a division.
1895+
By taking the modulo of the result of `rand::random()`, we're limiting the
1896+
values to be between 0 and 99. Then, we add one to the result, making it from 1
1897+
to 100.
1898+
1899+
Let's try to compile this using `cargo build`:
18931900

18941901
```{notrust,no_run}
18951902
$ cargo build
@@ -3669,9 +3676,10 @@ manually free this allocation! If we write
36693676
```
36703677

36713678
then Rust will automatically free `x` at the end of the block. This isn't
3672-
because Rust has a garbage collector -- it doesn't. Instead, when `x` goes out
3673-
of scope, Rust `free`s `x`. This Rust code will do the same thing as the
3674-
following C code:
3679+
because Rust has a garbage collector -- it doesn't. Instead, Rust uses static
3680+
analysis to determine the *lifetime* of `x`, and then generates code to free it
3681+
once it's sure the `x` won't be used again. This Rust code will do the same
3682+
thing as the following C code:
36753683

36763684
```{c,ignore}
36773685
{

branches/try2/src/doc/rust.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,6 @@ sequence (`/**`), are interpreted as a special syntax for `doc`
169169
`#[doc="..."]` around the body of the comment (this includes the comment
170170
characters themselves, ie `/// Foo` turns into `#[doc="/// Foo"]`).
171171

172-
`//!` comments apply to the parent of the comment, rather than the item that
173-
follows. `//!` comments are usually used to display information on the crate
174-
index page.
175-
176172
Non-doc comments are interpreted as a form of whitespace.
177173

178174
## Whitespace
@@ -1805,7 +1801,7 @@ module through the rules above. It essentially allows public access into the
18051801
re-exported item. For example, this program is valid:
18061802

18071803
~~~~
1808-
pub use self::implementation as api;
1804+
pub use api = self::implementation;
18091805
18101806
mod implementation {
18111807
pub fn f() {}

branches/try2/src/doc/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3112,7 +3112,7 @@ use farm::*;
31123112
However, that's not all. You can also rename an item while you're bringing it into scope:
31133113

31143114
~~~
3115-
use farm::chicken as egg_layer;
3115+
use egg_layer = farm::chicken;
31163116
# mod farm { pub fn chicken() { println!("Laying eggs is fun!") } }
31173117
// ...
31183118
@@ -3335,7 +3335,7 @@ you just have to import it with an `use` statement.
33353335
For example, it re-exports `range` which is defined in `std::iter::range`:
33363336

33373337
~~~
3338-
use std::iter::range as iter_range;
3338+
use iter_range = std::iter::range;
33393339
33403340
fn main() {
33413341
// `range` is imported by default

branches/try2/src/liballoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ extern crate libc;
8686

8787
#[deprecated = "use boxed instead"]
8888
#[cfg(not(test))]
89-
pub use boxed as owned;
89+
pub use owned = boxed;
9090

9191
// Heaps provided for low-level allocation strategies
9292

branches/try2/src/libcollections/bitv.rs

Lines changed: 5 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ use core::prelude::*;
6666
use core::cmp;
6767
use core::default::Default;
6868
use core::fmt;
69-
use core::iter::{Chain, Enumerate, Repeat, Skip, Take};
69+
use core::iter::Take;
7070
use core::iter;
7171
use core::slice;
7272
use core::uint;
@@ -75,22 +75,6 @@ use std::hash;
7575
use {Mutable, Set, MutableSet, MutableSeq};
7676
use vec::Vec;
7777

78-
type MatchWords<'a> = Chain<MaskWords<'a>, Skip<Take<Enumerate<Repeat<uint>>>>>;
79-
// Take two BitV's, and return iterators of their words, where the shorter one
80-
// has been padded with 0's
81-
fn match_words <'a,'b>(a: &'a Bitv, b: &'b Bitv) -> (MatchWords<'a>, MatchWords<'b>) {
82-
let a_len = a.storage.len();
83-
let b_len = b.storage.len();
84-
85-
// have to uselessly pretend to pad the longer one for type matching
86-
if a_len < b_len {
87-
(a.mask_words(0).chain(Repeat::new(0u).enumerate().take(b_len).skip(a_len)),
88-
b.mask_words(0).chain(Repeat::new(0u).enumerate().take(0).skip(0)))
89-
} else {
90-
(a.mask_words(0).chain(Repeat::new(0u).enumerate().take(0).skip(0)),
91-
b.mask_words(0).chain(Repeat::new(0u).enumerate().take(a_len).skip(b_len)))
92-
}
93-
}
9478

9579
static TRUE: bool = true;
9680
static FALSE: bool = false;
@@ -985,7 +969,7 @@ impl<'a> RandomAccessIterator<bool> for Bits<'a> {
985969
/// assert!(bv.eq_vec([true, true, false, true,
986970
/// false, false, false, false]));
987971
/// ```
988-
#[deriving(Clone)]
972+
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
989973
pub struct BitvSet(Bitv);
990974

991975
impl Default for BitvSet {
@@ -1008,32 +992,6 @@ impl Extendable<bool> for BitvSet {
1008992
}
1009993
}
1010994

1011-
impl PartialOrd for BitvSet {
1012-
#[inline]
1013-
fn partial_cmp(&self, other: &BitvSet) -> Option<Ordering> {
1014-
let (a_iter, b_iter) = match_words(self.get_ref(), other.get_ref());
1015-
iter::order::partial_cmp(a_iter, b_iter)
1016-
}
1017-
}
1018-
1019-
impl Ord for BitvSet {
1020-
#[inline]
1021-
fn cmp(&self, other: &BitvSet) -> Ordering {
1022-
let (a_iter, b_iter) = match_words(self.get_ref(), other.get_ref());
1023-
iter::order::cmp(a_iter, b_iter)
1024-
}
1025-
}
1026-
1027-
impl cmp::PartialEq for BitvSet {
1028-
#[inline]
1029-
fn eq(&self, other: &BitvSet) -> bool {
1030-
let (a_iter, b_iter) = match_words(self.get_ref(), other.get_ref());
1031-
iter::order::eq(a_iter, b_iter)
1032-
}
1033-
}
1034-
1035-
impl cmp::Eq for BitvSet {}
1036-
1037995
impl BitvSet {
1038996
/// Create a new bit vector set with initially no contents.
1039997
///
@@ -1183,18 +1141,10 @@ impl BitvSet {
11831141
// Unwrap Bitvs
11841142
let &BitvSet(ref mut self_bitv) = self;
11851143
let &BitvSet(ref other_bitv) = other;
1186-
11871144
// Expand the vector if necessary
11881145
self_bitv.reserve(other_bitv.capacity());
1189-
1190-
// virtually pad other with 0's for equal lengths
1191-
let mut other_words = {
1192-
let (_, result) = match_words(self_bitv, other_bitv);
1193-
result
1194-
};
1195-
1196-
// Apply values found in other
1197-
for (i, w) in other_words {
1146+
// Apply values
1147+
for (i, w) in other_bitv.mask_words(0) {
11981148
let old = self_bitv.storage[i];
11991149
let new = f(old, w);
12001150
*self_bitv.storage.get_mut(i) = new;
@@ -1521,7 +1471,7 @@ impl Set<uint> for BitvSet {
15211471

15221472
#[inline]
15231473
fn is_disjoint(&self, other: &BitvSet) -> bool {
1524-
self.intersection(other).next().is_none()
1474+
self.intersection(other).count() > 0
15251475
}
15261476

15271477
#[inline]
@@ -2263,82 +2213,6 @@ mod tests {
22632213
assert!(set1.is_subset(&set2)); // { 2 } { 2, 4 }
22642214
}
22652215

2266-
#[test]
2267-
fn test_bitv_set_is_disjoint() {
2268-
let a = BitvSet::from_bitv(from_bytes([0b10100010]));
2269-
let b = BitvSet::from_bitv(from_bytes([0b01000000]));
2270-
let c = BitvSet::new();
2271-
let d = BitvSet::from_bitv(from_bytes([0b00110000]));
2272-
2273-
assert!(!a.is_disjoint(&d));
2274-
assert!(!d.is_disjoint(&a));
2275-
2276-
assert!(a.is_disjoint(&b))
2277-
assert!(a.is_disjoint(&c))
2278-
assert!(b.is_disjoint(&a))
2279-
assert!(b.is_disjoint(&c))
2280-
assert!(c.is_disjoint(&a))
2281-
assert!(c.is_disjoint(&b))
2282-
}
2283-
2284-
#[test]
2285-
fn test_bitv_set_intersect_with() {
2286-
// Explicitly 0'ed bits
2287-
let mut a = BitvSet::from_bitv(from_bytes([0b10100010]));
2288-
let mut b = BitvSet::from_bitv(from_bytes([0b00000000]));
2289-
let c = a.clone();
2290-
a.intersect_with(&b);
2291-
b.intersect_with(&c);
2292-
assert!(a.is_empty());
2293-
assert!(b.is_empty());
2294-
2295-
// Uninitialized bits should behave like 0's
2296-
let mut a = BitvSet::from_bitv(from_bytes([0b10100010]));
2297-
let mut b = BitvSet::new();
2298-
let c = a.clone();
2299-
a.intersect_with(&b);
2300-
b.intersect_with(&c);
2301-
assert!(a.is_empty());
2302-
assert!(b.is_empty());
2303-
2304-
// Standard
2305-
let mut a = BitvSet::from_bitv(from_bytes([0b10100010]));
2306-
let mut b = BitvSet::from_bitv(from_bytes([0b01100010]));
2307-
let c = a.clone();
2308-
a.intersect_with(&b);
2309-
b.intersect_with(&c);
2310-
assert_eq!(a.len(), 2);
2311-
assert_eq!(b.len(), 2);
2312-
}
2313-
2314-
#[test]
2315-
fn test_bitv_set_eq() {
2316-
let a = BitvSet::from_bitv(from_bytes([0b10100010]));
2317-
let b = BitvSet::from_bitv(from_bytes([0b00000000]));
2318-
let c = BitvSet::new();
2319-
2320-
assert!(a == a);
2321-
assert!(a != b);
2322-
assert!(a != c);
2323-
assert!(b == b);
2324-
assert!(b == c);
2325-
assert!(c == c);
2326-
}
2327-
2328-
#[test]
2329-
fn test_bitv_set_cmp() {
2330-
let a = BitvSet::from_bitv(from_bytes([0b10100010]));
2331-
let b = BitvSet::from_bitv(from_bytes([0b00000000]));
2332-
let c = BitvSet::new();
2333-
2334-
assert_eq!(a.cmp(&b), Greater);
2335-
assert_eq!(a.cmp(&c), Greater);
2336-
assert_eq!(b.cmp(&a), Less);
2337-
assert_eq!(b.cmp(&c), Equal);
2338-
assert_eq!(c.cmp(&a), Less);
2339-
assert_eq!(c.cmp(&b), Equal);
2340-
}
2341-
23422216
#[test]
23432217
fn test_bitv_remove() {
23442218
let mut a = BitvSet::new();

branches/try2/src/libcollections/hash/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ use core::mem;
7373
use vec::Vec;
7474

7575
/// Reexport the `sip::hash` function as our default hasher.
76-
pub use self::sip::hash as hash;
76+
pub use hash = self::sip::hash;
7777

7878
pub mod sip;
7979

branches/try2/src/libcollections/str.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ the string is valid for the `'static` lifetime, otherwise known as the
4444
lifetime of the entire program. As can be inferred from the type, these static
4545
strings are not mutable.
4646
47+
# Mutability
48+
49+
Many languages have immutable strings by default, and Rust has a particular
50+
flavor on this idea. As with the rest of Rust types, strings are immutable by
51+
default. If a string is declared as `mut`, however, it may be mutated. This
52+
works the same way as the rest of Rust's type system in the sense that if
53+
there's a mutable reference to a string, there may only be one mutable reference
54+
to that string. With these guarantees, strings can easily transition between
55+
being mutable/immutable with the same benefits of having mutable strings in
56+
other languages.
57+
4758
# Representation
4859
4960
Rust's string type, `str`, is a sequence of unicode scalar values encoded as a

branches/try2/src/libcollections/string.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ use core::fmt;
1919
use core::mem;
2020
use core::ptr;
2121
// FIXME: ICE's abound if you import the `Slice` type while importing `Slice` trait
22-
use core::raw::Slice as RawSlice;
22+
use RawSlice = core::raw::Slice;
2323

2424
use {Mutable, MutableSeq};
2525
use hash;
2626
use str;
2727
use str::{CharRange, StrAllocating, MaybeOwned, Owned};
28-
use str::Slice as MaybeOwnedSlice; // So many `Slice`s...
28+
use MaybeOwnedSlice = str::Slice; // So many `Slice`s...
2929
use vec::Vec;
3030

3131
/// A growable string stored as a UTF-8 encoded buffer.

branches/try2/src/libcollections/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
use core::prelude::*;
1414

1515
use alloc::heap::{allocate, reallocate, deallocate};
16+
use RawSlice = core::raw::Slice;
1617
use core::cmp::max;
1718
use core::default::Default;
1819
use core::fmt;
1920
use core::mem;
2021
use core::num;
2122
use core::ptr;
22-
use core::raw::Slice as RawSlice;
2323
use core::uint;
2424

2525
use {Mutable, MutableSeq};

branches/try2/src/libcore/kinds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ by the compiler automatically for the types to which they apply.
2121
*/
2222

2323
#[deprecated = "This has been renamed to Sync"]
24-
pub use self::Sync as Share;
24+
pub use Share = self::Sync;
2525

2626
/// Types able to be transferred across task boundaries.
2727
#[lang="send"]

branches/try2/src/libcore/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub mod collections;
107107
/// Deprecated module in favor of `std::cell`
108108
pub mod ty {
109109
#[deprecated = "this type has been renamed to `UnsafeCell`"]
110-
pub use cell::UnsafeCell as Unsafe;
110+
pub use Unsafe = cell::UnsafeCell;
111111
}
112112

113113
/* Core types and methods on primitives */

0 commit comments

Comments
 (0)