Skip to content

Commit b16896f

Browse files
committed
---
yaml --- r: 68462 b: refs/heads/auto c: 5d2e565 h: refs/heads/master v: v3
1 parent 7064d0f commit b16896f

File tree

210 files changed

+3758
-2068
lines changed

Some content is hidden

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

210 files changed

+3758
-2068
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: a2227f9e0c295c3582683129a8511d7660b644a0
17+
refs/heads/auto: 5d2e565bb1f4566bdaab053876bacad72c57f582
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/Makefile.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ endif
141141
CFG_GIT_DIR := $(CFG_SRC_DIR).git
142142
CFG_RELEASE = 0.7-pre
143143
CFG_VERSION = $(CFG_RELEASE)
144+
# windows exe's need numeric versions - don't use anything but
145+
# numbers and dots here
146+
CFG_VERSION_WIN = 0.7
144147

145148
ifneq ($(wildcard $(CFG_GIT)),)
146149
ifneq ($(wildcard $(CFG_GIT_DIR)),)
@@ -311,6 +314,7 @@ $(foreach host,$(CFG_HOST_TRIPLES), \
311314
export CFG_SRC_DIR
312315
export CFG_BUILD_DIR
313316
export CFG_VERSION
317+
export CFG_VERSION_WIN
314318
export CFG_BUILD_TRIPLE
315319
export CFG_LLVM_ROOT
316320
export CFG_ENABLE_MINGW_CROSS

branches/auto/RELEASES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ Version 0.7 (July 2013)
101101
dynamic borrowcheck failures for debugging.
102102
* rustdoc has a nicer stylesheet.
103103
* Various improvements to rustdoc.
104+
* Improvements to rustpkg (see the detailed release notes)
104105

105106
* Other
106107
* More and improved library documentation.

branches/auto/doc/rust.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,13 +2862,13 @@ call to the method `make_string`.
28622862
Types in Rust are categorized into kinds, based on various properties of the components of the type.
28632863
The kinds are:
28642864

2865-
`Const`
2865+
`Freeze`
28662866
: Types of this kind are deeply immutable;
28672867
they contain no mutable memory locations directly or indirectly via pointers.
2868-
`Owned`
2868+
`Send`
28692869
: Types of this kind can be safely sent between tasks.
28702870
This kind includes scalars, owning pointers, owned closures, and
2871-
structural types containing only other owned types. All `Owned` types are `Static`.
2871+
structural types containing only other owned types. All `Send` types are `Static`.
28722872
`Static`
28732873
: Types of this kind do not contain any borrowed pointers;
28742874
this can be a useful guarantee for code that breaks borrowing assumptions using [`unsafe` operations](#unsafe-functions).
@@ -2882,7 +2882,7 @@ The kinds are:
28822882
trait provides a single method `finalize` that takes no parameters, and is run
28832883
when values of the type are dropped. Such a method is called a "destructor",
28842884
and are always executed in "top-down" order: a value is completely destroyed
2885-
before any of the values it owns run their destructors. Only `Owned` types
2885+
before any of the values it owns run their destructors. Only `Send` types
28862886
that do not implement `Copy` can implement `Drop`.
28872887

28882888
> **Note:** The `finalize` method may be renamed in future versions of Rust.
@@ -2968,10 +2968,10 @@ frame they are allocated within.
29682968
A task owns all memory it can *safely* reach through local variables,
29692969
as well as managed, owning and borrowed pointers.
29702970

2971-
When a task sends a value that has the `Owned` trait to another task,
2971+
When a task sends a value that has the `Send` trait to another task,
29722972
it loses ownership of the value sent and can no longer refer to it.
29732973
This is statically guaranteed by the combined use of "move semantics",
2974-
and the compiler-checked _meaning_ of the `Owned` trait:
2974+
and the compiler-checked _meaning_ of the `Send` trait:
29752975
it is only instantiated for (transitively) sendable kinds of data constructor and pointers,
29762976
never including managed or borrowed pointers.
29772977

@@ -3116,7 +3116,7 @@ These include:
31163116
- read-only and read-write shared variables with various safe mutual exclusion patterns
31173117
- simple locks and semaphores
31183118

3119-
When such facilities carry values, the values are restricted to the [`Owned` type-kind](#type-kinds).
3119+
When such facilities carry values, the values are restricted to the [`Send` type-kind](#type-kinds).
31203120
Restricting communication interfaces to this kind ensures that no borrowed or managed pointers move between tasks.
31213121
Thus access to an entire data structure can be mediated through its owning "root" value;
31223122
no further locking or copying is required to avoid data races within the substructure of such a value.

branches/auto/doc/rustpkg.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,22 @@ When building a package that is in a `git` repository,
9595
When building a package that is not under version control,
9696
or that has no tags, `rustpkg` assumes the intended version is 0.1.
9797

98+
# Dependencies
99+
100+
rustpkg infers dependencies from `extern mod` directives.
101+
Thus, there should be no need to pass a `-L` flag to rustpkg to tell it where to find a library.
102+
(In the future, it will also be possible to write an `extern mod` directive referring to a remote package.)
103+
98104
# Custom build scripts
99105

100106
A file called `pkg.rs` at the root level in a workspace is called a *package script*.
101107
If a package script exists, rustpkg executes it to build the package
102108
rather than inferring crates as described previously.
103109

110+
Inside `pkg.rs`, it's possible to call back into rustpkg to finish up the build.
111+
`rustpkg::api` contains functions to build, install, or clean libraries and executables
112+
in the way rustpkg normally would without custom build logic.
113+
104114
# Command reference
105115

106116
## build
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
% Containers and iterators
2+
3+
# Containers
4+
5+
The container traits are defined in the `std::container` module.
6+
7+
## Unique and managed vectors
8+
9+
Vectors have `O(1)` indexing and removal from the end, along with `O(1)`
10+
amortized insertion. Vectors are the most common container in Rust, and are
11+
flexible enough to fit many use cases.
12+
13+
Vectors can also be sorted and used as efficient lookup tables with the
14+
`std::vec::bsearch` function, if all the elements are inserted at one time and
15+
deletions are unnecessary.
16+
17+
## Maps and sets
18+
19+
Maps are collections of unique keys with corresponding values, and sets are
20+
just unique keys without a corresponding value. The `Map` and `Set` traits in
21+
`std::container` define the basic interface.
22+
23+
The standard library provides three owned map/set types:
24+
25+
* `std::hashmap::HashMap` and `std::hashmap::HashSet`, requiring the keys to
26+
implement `Eq` and `Hash`
27+
* `std::trie::TrieMap` and `std::trie::TrieSet`, requiring the keys to be `uint`
28+
* `extra::treemap::TreeMap` and `extra::treemap::TreeSet`, requiring the keys
29+
to implement `TotalOrd`
30+
31+
These maps do not use managed pointers so they can be sent between tasks as
32+
long as the key and value types are sendable. Neither the key or value type has
33+
to be copyable.
34+
35+
The `TrieMap` and `TreeMap` maps are ordered, while `HashMap` uses an arbitrary
36+
order.
37+
38+
Each `HashMap` instance has a random 128-bit key to use with a keyed hash,
39+
making the order of a set of keys in a given hash table randomized. Rust
40+
provides a [SipHash](https://131002.net/siphash/) implementation for any type
41+
implementing the `IterBytes` trait.
42+
43+
## Double-ended queues
44+
45+
The `extra::deque` module implements a double-ended queue with `O(1)` amortized
46+
inserts and removals from both ends of the container. It also has `O(1)`
47+
indexing like a vector. The contained elements are not required to be copyable,
48+
and the queue will be sendable if the contained type is sendable.
49+
50+
## Priority queues
51+
52+
The `extra::priority_queue` module implements a queue ordered by a key. The
53+
contained elements are not required to be copyable, and the queue will be
54+
sendable if the contained type is sendable.
55+
56+
Insertions have `O(log n)` time complexity and checking or popping the largest
57+
element is `O(1)`. Converting a vector to a priority queue can be done
58+
in-place, and has `O(n)` complexity. A priority queue can also be converted to
59+
a sorted vector in-place, allowing it to be used for an `O(n log n)` in-place
60+
heapsort.
61+
62+
# Iterators
63+
64+
## Iteration protocol
65+
66+
The iteration protocol is defined by the `Iterator` trait in the
67+
`std::iterator` module. The minimal implementation of the trait is a `next`
68+
method, yielding the next element from an iterator object:
69+
70+
~~~
71+
/// An infinite stream of zeroes
72+
struct ZeroStream;
73+
74+
impl Iterator<int> for ZeroStream {
75+
fn next(&mut self) -> Option<int> {
76+
Some(0)
77+
}
78+
}
79+
~~~~
80+
81+
Reaching the end of the iterator is signalled by returning `None` instead of
82+
`Some(item)`:
83+
84+
~~~
85+
/// A stream of N zeroes
86+
struct ZeroStream {
87+
priv remaining: uint
88+
}
89+
90+
impl ZeroStream {
91+
fn new(n: uint) -> ZeroStream {
92+
ZeroStream { remaining: n }
93+
}
94+
}
95+
96+
impl Iterator<int> for ZeroStream {
97+
fn next(&mut self) -> Option<int> {
98+
if self.remaining == 0 {
99+
None
100+
} else {
101+
self.remaining -= 1;
102+
Some(0)
103+
}
104+
}
105+
}
106+
~~~
107+
108+
## Container iterators
109+
110+
Containers implement iteration over the contained elements by returning an
111+
iterator object. For example, vectors have four iterators available:
112+
113+
* `vector.iter()`, for immutable references to the elements
114+
* `vector.mut_iter()`, for mutable references to the elements
115+
* `vector.rev_iter()`, for immutable references to the elements in reverse order
116+
* `vector.mut_rev_iter()`, for mutable references to the elements in reverse order
117+
118+
### Freezing
119+
120+
Unlike most other languages with external iterators, Rust has no *iterator
121+
invalidation*. As long an iterator is still in scope, the compiler will prevent
122+
modification of the container through another handle.
123+
124+
~~~
125+
let mut xs = [1, 2, 3];
126+
{
127+
let _it = xs.iter();
128+
129+
// the vector is frozen for this scope, the compiler will statically
130+
// prevent modification
131+
}
132+
// the vector becomes unfrozen again at the end of the scope
133+
~~~
134+
135+
These semantics are due to most container iterators being implemented with `&`
136+
and `&mut`.
137+
138+
## Iterator adaptors
139+
140+
The `IteratorUtil` trait implements common algorithms as methods extending
141+
every `Iterator` implementation. For example, the `fold` method will accumulate
142+
the items yielded by an `Iterator` into a single value:
143+
144+
~~~
145+
let xs = [1, 9, 2, 3, 14, 12];
146+
let result = xs.iter().fold(0, |accumulator, item| accumulator - *item);
147+
assert_eq!(result, -41);
148+
~~~
149+
150+
Some adaptors return an adaptor object implementing the `Iterator` trait itself:
151+
152+
~~~
153+
let xs = [1, 9, 2, 3, 14, 12];
154+
let ys = [5, 2, 1, 8];
155+
let sum = xs.iter().chain_(ys.iter()).fold(0, |a, b| a + *b);
156+
assert_eq!(sum, 57);
157+
~~~
158+
159+
Note that some adaptors like the `chain_` method above use a trailing
160+
underscore to work around an issue with method resolve. The underscores will be
161+
dropped when they become unnecessary.
162+
163+
## For loops
164+
165+
The `for` loop syntax is currently in transition, and will switch from the old
166+
closure-based iteration protocol to iterator objects. For now, the `advance`
167+
adaptor is required as a compatibility shim to use iterators with for loops.
168+
169+
~~~
170+
let xs = [2, 3, 5, 7, 11, 13, 17];
171+
172+
// print out all the elements in the vector
173+
for xs.iter().advance |x| {
174+
println(x.to_str())
175+
}
176+
177+
// print out all but the first 3 elements in the vector
178+
for xs.iter().skip(3).advance |x| {
179+
println(x.to_str())
180+
}
181+
~~~
182+
183+
For loops are *often* used with a temporary iterator object, as above. They can
184+
also advance the state of an iterator in a mutable location:
185+
186+
~~~
187+
let xs = [1, 2, 3, 4, 5];
188+
let ys = ["foo", "bar", "baz", "foobar"];
189+
190+
// create an iterator yielding tuples of elements from both vectors
191+
let mut it = xs.iter().zip(ys.iter());
192+
193+
// print out the pairs of elements up to (&3, &"baz")
194+
for it.advance |(x, y)| {
195+
println(fmt!("%d %s", *x, *y));
196+
197+
if *x == 3 {
198+
break;
199+
}
200+
}
201+
202+
// yield and print the last pair from the iterator
203+
println(fmt!("last: %?", it.next()));
204+
205+
// the iterator is now fully consumed
206+
assert!(it.next().is_none());
207+
~~~

branches/auto/doc/tutorial-ffi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub struct Unique<T> {
159159
priv ptr: *mut T
160160
}
161161
162-
impl<T: Owned> Unique<T> {
162+
impl<T: Send> Unique<T> {
163163
pub fn new(value: T) -> Unique<T> {
164164
unsafe {
165165
let ptr = malloc(std::sys::size_of::<T>() as size_t) as *mut T;
@@ -182,7 +182,7 @@ impl<T: Owned> Unique<T> {
182182
}
183183
184184
#[unsafe_destructor]
185-
impl<T: Owned> Drop for Unique<T> {
185+
impl<T: Send> Drop for Unique<T> {
186186
fn drop(&self) {
187187
unsafe {
188188
let x = intrinsics::init(); // dummy value to swap in

0 commit comments

Comments
 (0)