Skip to content

Commit 7d69837

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 60245b9 + a4ec8af commit 7d69837

Some content is hidden

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

110 files changed

+1957
-721
lines changed

doc/rust.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3168,7 +3168,7 @@ Raw pointers (`*`)
31683168
: Raw pointers are pointers without safety or liveness guarantees.
31693169
Raw pointers are written `*content`,
31703170
for example `*int` means a raw pointer to an integer.
3171-
Copying or dropping a raw pointer is has no effect on the lifecycle of any other value.
3171+
Copying or dropping a raw pointer has no effect on the lifecycle of any other value.
31723172
Dereferencing a raw pointer or converting it to any other pointer type is an [`unsafe` operation](#unsafe-functions).
31733173
Raw pointers are generally discouraged in Rust code;
31743174
they exist to support interoperability with foreign code,
@@ -3395,16 +3395,23 @@ a [temporary](#lvalues-rvalues-and-temporaries), or a local variable.
33953395
A _local variable_ (or *stack-local* allocation) holds a value directly,
33963396
allocated within the stack's memory. The value is a part of the stack frame.
33973397

3398-
Local variables are immutable unless declared with `let mut`. The
3399-
`mut` keyword applies to all local variables declared within that
3400-
declaration (so `let mut (x, y) = ...` declares two mutable variables, `x` and
3401-
`y`).
3398+
Local variables are immutable unless declared otherwise like: `let mut x = ...`.
34023399

34033400
Function parameters are immutable unless declared with `mut`. The
34043401
`mut` keyword applies only to the following parameter (so `|mut x, y|`
34053402
and `fn f(mut x: ~int, y: ~int)` declare one mutable variable `x` and
34063403
one immutable variable `y`).
34073404

3405+
Methods that take either `self` or `~self` can optionally place them in a
3406+
mutable slot by prefixing them with `mut` (similar to regular arguments):
3407+
3408+
~~~
3409+
trait Changer {
3410+
fn change(mut self) -> Self;
3411+
fn modify(mut ~self) -> ~Self;
3412+
}
3413+
~~~
3414+
34083415
Local variables are not initialized when allocated; the entire frame worth of
34093416
local variables are allocated at once, on frame-entry, in an uninitialized
34103417
state. Subsequent statements within a function may or may not initialize the

doc/tutorial.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -151,22 +151,6 @@ declaration to appear at the top level of the file: all statements must
151151
live inside a function. Rust programs can also be compiled as
152152
libraries, and included in other programs.
153153

154-
## Using the rust tool
155-
156-
While using `rustc` directly to generate your executables, and then
157-
running them manually is a perfectly valid way to test your code,
158-
for smaller projects, prototypes, or if you're a beginner, it might be
159-
more convenient to use the `rust` tool.
160-
161-
The `rust` tool provides central access to the other rust tools,
162-
as well as handy shortcuts for directly running source files.
163-
For example, if you have a file `foo.rs` in your current directory,
164-
`rust run foo.rs` would attempt to compile it and, if successful,
165-
directly run the resulting binary.
166-
167-
To get a list of all available commands, simply call `rust` without any
168-
argument.
169-
170154
## Editing Rust code
171155

172156
There are vim highlighting and indentation scripts in the Rust source

mk/tests.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ $(3)/stage$(1)/test/rustpkgtest-$(2)$$(X_$(2)): \
370370
$$(SREQ$(1)_T_$(2)_H_$(3)) \
371371
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX_$(2)) \
372372
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2)) \
373+
$$(HBIN$(1)_H_$(3))/rustpkg$$(X_$(2)) \
373374
$$(TBIN$(1)_T_$(2)_H_$(3))/rustpkg$$(X_$(2)) \
374375
$$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X_$(2))
375376
@$$(call E, compile_and_link: $$@)

src/libextra/arc.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,15 +521,15 @@ fn borrow_rwlock<T:Freeze + Send>(state: *mut RWArcInner<T>) -> *RWLock {
521521

522522
/// The "write permission" token used for RWArc.write_downgrade().
523523
pub struct RWWriteMode<'self, T> {
524-
data: &'self mut T,
525-
token: sync::RWLockWriteMode<'self>,
526-
poison: PoisonOnFail,
524+
priv data: &'self mut T,
525+
priv token: sync::RWLockWriteMode<'self>,
526+
priv poison: PoisonOnFail,
527527
}
528528

529529
/// The "read permission" token used for RWArc.write_downgrade().
530530
pub struct RWReadMode<'self, T> {
531-
data: &'self T,
532-
token: sync::RWLockReadMode<'self>,
531+
priv data: &'self T,
532+
priv token: sync::RWLockReadMode<'self>,
533533
}
534534

535535
impl<'self, T:Freeze + Send> RWWriteMode<'self, T> {

src/libextra/base64.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ pub enum CharacterSet {
2222
/// Contains configuration parameters for `to_base64`.
2323
pub struct Config {
2424
/// Character set to use
25-
char_set: CharacterSet,
25+
priv char_set: CharacterSet,
2626
/// True to pad output with `=` characters
27-
pad: bool,
27+
priv pad: bool,
2828
/// `Some(len)` to wrap lines at `len`, `None` to disable line wrapping
29-
line_length: Option<uint>
29+
priv line_length: Option<uint>
3030
}
3131

3232
/// Configuration for RFC 4648 standard base64 encoding
@@ -318,7 +318,7 @@ mod test {
318318
use std::vec;
319319
320320
do 1000.times {
321-
let times = task_rng().gen_integer_range(1u, 100);
321+
let times = task_rng().gen_range(1u, 100);
322322
let v = vec::from_fn(times, |_| random::<u8>());
323323
assert_eq!(v.to_base64(STANDARD).from_base64().unwrap(), v);
324324
}

src/libextra/bitv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ enum Op {Union, Intersect, Assign, Difference}
226226
#[deriving(Clone)]
227227
pub struct Bitv {
228228
/// Internal representation of the bit vector (small or large)
229-
rep: BitvVariant,
229+
priv rep: BitvVariant,
230230
/// The number of valid bits in the internal representation
231-
nbits: uint
231+
priv nbits: uint
232232
}
233233

234234
fn die() -> ! {

src/libextra/crypto/cryptoutil.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ pub mod test {
365365
digest.reset();
366366

367367
while count < total_size {
368-
let next: uint = rng.gen_integer_range(0, 2 * blocksize + 1);
368+
let next: uint = rng.gen_range(0, 2 * blocksize + 1);
369369
let remaining = total_size - count;
370370
let size = if next > remaining { remaining } else { next };
371371
digest.input(buffer.slice_to(size));

src/libextra/ebml.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl Doc {
5050
}
5151

5252
pub struct TaggedDoc {
53-
tag: uint,
53+
priv tag: uint,
5454
doc: Doc,
5555
}
5656

src/libextra/fileinput.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ struct FileInput_ {
155155
// "self.fi" -> "self." and renaming FileInput_. Documentation above
156156
// will likely have to be updated to use `let mut in = ...`.
157157
pub struct FileInput {
158-
fi: @mut FileInput_
158+
priv fi: @mut FileInput_
159159
}
160160

161161
impl FileInput {

src/libextra/flate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ mod tests {
113113
let mut r = rand::rng();
114114
let mut words = ~[];
115115
do 20.times {
116-
let range = r.gen_integer_range(1u, 10);
116+
let range = r.gen_range(1u, 10);
117117
words.push(r.gen_vec::<u8>(range));
118118
}
119119
do 20.times {

src/libextra/getopts.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub struct Opt {
119119
/// How often it can occur
120120
occur: Occur,
121121
/// Which options it aliases
122-
aliases: ~[Opt],
122+
priv aliases: ~[Opt],
123123
}
124124

125125
/// Describes wether an option is given at all or has a value.
@@ -134,9 +134,9 @@ enum Optval {
134134
#[deriving(Clone, Eq)]
135135
pub struct Matches {
136136
/// Options that matched
137-
opts: ~[Opt],
137+
priv opts: ~[Opt],
138138
/// Values of the Options that matched
139-
vals: ~[~[Optval]],
139+
priv vals: ~[~[Optval]],
140140
/// Free string fragments
141141
free: ~[~str]
142142
}

src/libextra/glob.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,21 +480,21 @@ pub struct MatchOptions {
480480
* currently only considers upper/lower case relationships between ASCII characters,
481481
* but in future this might be extended to work with Unicode.
482482
*/
483-
case_sensitive: bool,
483+
priv case_sensitive: bool,
484484

485485
/**
486486
* If this is true then path-component separator characters (e.g. `/` on Posix)
487487
* must be matched by a literal `/`, rather than by `*` or `?` or `[...]`
488488
*/
489-
require_literal_separator: bool,
489+
priv require_literal_separator: bool,
490490

491491
/**
492492
* If this is true then paths that contain components that start with a `.` will
493493
* not match unless the `.` appears literally in the pattern: `*`, `?` or `[...]`
494494
* will not match. This is useful because such files are conventionally considered
495495
* hidden on Unix systems and it might be desirable to skip them when listing files.
496496
*/
497-
require_literal_leading_dot: bool
497+
priv require_literal_leading_dot: bool
498498
}
499499

500500
impl MatchOptions {

src/libextra/io_util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ use std::cast;
1717
/// An implementation of the io::Reader interface which reads a buffer of bytes
1818
pub struct BufReader {
1919
/// The buffer of bytes to read
20-
buf: ~[u8],
20+
priv buf: ~[u8],
2121
/// The current position in the buffer of bytes
22-
pos: @mut uint
22+
priv pos: @mut uint
2323
}
2424

2525
impl BufReader {

src/libextra/json.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ pub type Object = TreeMap<~str, Json>;
4949
/// returned
5050
pub struct Error {
5151
/// The line number at which the error occurred
52-
line: uint,
52+
priv line: uint,
5353
/// The column number at which the error occurred
54-
col: uint,
54+
priv col: uint,
5555
/// A message describing the type of the error
56-
msg: @~str,
56+
priv msg: @~str,
5757
}
5858

5959
fn escape_str(s: &str) -> ~str {

src/libextra/num/rational.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use super::bigint::BigInt;
2020
#[deriving(Clone)]
2121
#[allow(missing_doc)]
2222
pub struct Ratio<T> {
23-
numer: T,
24-
denom: T
23+
priv numer: T,
24+
priv denom: T
2525
}
2626

2727
/// Alias for a `Ratio` of machine-sized integers.

src/libextra/semver.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,17 @@ impl ToStr for Identifier {
7171
#[deriving(Clone, Eq)]
7272
pub struct Version {
7373
/// The major version, to be incremented on incompatible changes.
74-
major: uint,
74+
priv major: uint,
7575
/// The minor version, to be incremented when functionality is added in a
7676
/// backwards-compatible manner.
77-
minor: uint,
77+
priv minor: uint,
7878
/// The patch version, to be incremented when backwards-compatible bug
7979
/// fixes are made.
80-
patch: uint,
80+
priv patch: uint,
8181
/// The pre-release version identifier, if one exists.
82-
pre: ~[Identifier],
82+
priv pre: ~[Identifier],
8383
/// The build metadata, ignored when determining version precedence.
84-
build: ~[Identifier],
84+
priv build: ~[Identifier],
8585
}
8686

8787
impl ToStr for Version {

src/libextra/sort.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,8 +1069,8 @@ mod big_tests {
10691069
isSorted(arr);
10701070

10711071
do 3.times {
1072-
let i1 = rng.gen_integer_range(0u, n);
1073-
let i2 = rng.gen_integer_range(0u, n);
1072+
let i1 = rng.gen_range(0u, n);
1073+
let i2 = rng.gen_range(0u, n);
10741074
arr.swap(i1, i2);
10751075
}
10761076
tim_sort(arr); // 3sort
@@ -1088,7 +1088,7 @@ mod big_tests {
10881088
isSorted(arr);
10891089

10901090
do (n/100).times {
1091-
let idx = rng.gen_integer_range(0u, n);
1091+
let idx = rng.gen_range(0u, n);
10921092
arr[idx] = rng.gen();
10931093
}
10941094
tim_sort(arr);
@@ -1141,8 +1141,8 @@ mod big_tests {
11411141
isSorted(arr);
11421142

11431143
do 3.times {
1144-
let i1 = rng.gen_integer_range(0u, n);
1145-
let i2 = rng.gen_integer_range(0u, n);
1144+
let i1 = rng.gen_range(0u, n);
1145+
let i2 = rng.gen_range(0u, n);
11461146
arr.swap(i1, i2);
11471147
}
11481148
tim_sort(arr); // 3sort
@@ -1160,7 +1160,7 @@ mod big_tests {
11601160
isSorted(arr);
11611161

11621162
do (n/100).times {
1163-
let idx = rng.gen_integer_range(0u, n);
1163+
let idx = rng.gen_range(0u, n);
11641164
arr[idx] = @rng.gen();
11651165
}
11661166
tim_sort(arr);

src/libextra/stats.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,23 @@ pub trait Stats {
105105
#[deriving(Clone, Eq)]
106106
#[allow(missing_doc)]
107107
pub struct Summary {
108-
sum: f64,
108+
priv sum: f64,
109+
// public
109110
min: f64,
111+
// public
110112
max: f64,
111-
mean: f64,
113+
priv mean: f64,
114+
// public
112115
median: f64,
113-
var: f64,
114-
std_dev: f64,
115-
std_dev_pct: f64,
116+
priv var: f64,
117+
priv std_dev: f64,
118+
priv std_dev_pct: f64,
119+
// public
116120
median_abs_dev: f64,
121+
// public
117122
median_abs_dev_pct: f64,
118-
quartiles: (f64,f64,f64),
119-
iqr: f64,
123+
priv quartiles: (f64,f64,f64),
124+
priv iqr: f64,
120125
}
121126

122127
impl Summary {

src/libextra/sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ impl Semaphore {
376376
* A task which fails while holding a mutex will unlock the mutex as it
377377
* unwinds.
378378
*/
379-
pub struct Mutex { priv sem: Sem<~[WaitQueue]> }
380379

380+
pub struct Mutex { priv sem: Sem<~[WaitQueue]> }
381381
impl Clone for Mutex {
382382
/// Create a new handle to the mutex.
383383
fn clone(&self) -> Mutex { Mutex { sem: Sem((*self.sem).clone()) } }
@@ -663,8 +663,8 @@ impl RWLock {
663663
}
664664

665665
/// The "write permission" token used for rwlock.write_downgrade().
666-
pub struct RWLockWriteMode<'self> { priv lock: &'self RWLock, priv token: NonCopyable }
667666
667+
pub struct RWLockWriteMode<'self> { priv lock: &'self RWLock, priv token: NonCopyable }
668668
/// The "read permission" token used for rwlock.write_downgrade().
669669
pub struct RWLockReadMode<'self> { priv lock: &'self RWLock,
670670
priv token: NonCopyable }

src/libextra/task_pool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ enum Msg<T> {
2828
}
2929

3030
pub struct TaskPool<T> {
31-
channels: ~[Chan<Msg<T>>],
32-
next_index: uint,
31+
priv channels: ~[Chan<Msg<T>>],
32+
priv next_index: uint,
3333
}
3434

3535
#[unsafe_destructor]

src/libextra/term.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ fn cap_for_attr(attr: attr::Attr) -> &'static str {
9595

9696
#[cfg(not(target_os = "win32"))]
9797
pub struct Terminal {
98-
num_colors: u16,
98+
priv num_colors: u16,
9999
priv out: @io::Writer,
100100
priv ti: ~TermInfo
101101
}
102102

103103
#[cfg(target_os = "win32")]
104104
pub struct Terminal {
105-
num_colors: u16,
105+
priv num_colors: u16,
106106
priv out: @io::Writer,
107107
}
108108

src/libextra/terminfo/parm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ pub enum Param {
4848
/// Container for static and dynamic variable arrays
4949
pub struct Variables {
5050
/// Static variables A-Z
51-
sta: [Param, ..26],
51+
priv sta: [Param, ..26],
5252
/// Dynamic variables a-z
53-
dyn: [Param, ..26]
53+
priv dyn: [Param, ..26]
5454
}
5555

5656
impl Variables {

0 commit comments

Comments
 (0)