Skip to content

Commit c7c769d

Browse files
committed
auto merge of #9315 : thestinger/rust/doc, r=alexcrichton
This also renames the section, as managed vectors cannot be resized (since it would invalidate the other references).
2 parents 7f826cb + f0630fd commit c7c769d

File tree

2 files changed

+33
-28
lines changed

2 files changed

+33
-28
lines changed

doc/tutorial-container.md

+31-26
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
The container traits are defined in the `std::container` module.
66

7-
## Unique and managed vectors
7+
## Unique vectors
88

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.
9+
Vectors have `O(1)` indexing, push (to the end) and pop (from the end). Vectors
10+
are the most common container in Rust, and are flexible enough to fit many use
11+
cases.
1212

1313
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
14+
`bsearch()` method, if all the elements are inserted at one time and
1515
deletions are unnecessary.
1616

1717
## Maps and sets
@@ -42,10 +42,15 @@ implementing the `IterBytes` trait.
4242

4343
## Double-ended queues
4444

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.
45+
The `extra::ringbuf` module implements a double-ended queue with `O(1)`
46+
amortized inserts and removals from both ends of the container. It also has
47+
`O(1)` indexing like a vector. The contained elements are not required to be
48+
copyable, and the queue will be sendable if the contained type is sendable.
49+
Its interface `Deque` is defined in `extra::collections`.
50+
51+
The `extra::dlist` module implements a double-ended linked list, also
52+
implementing the `Deque` trait, with `O(1)` removals and inserts at either end,
53+
and `O(1)` concatenation.
4954

5055
## Priority queues
5156

@@ -197,11 +202,11 @@ The function `range` (or `range_inclusive`) allows to simply iterate through a g
197202
198203
~~~
199204
for i in range(0, 5) {
200-
printf!("%d ", i) // prints "0 1 2 3 4"
205+
print!("{} ", i) // prints "0 1 2 3 4"
201206
}
202207

203208
for i in std::iter::range_inclusive(0, 5) { // needs explicit import
204-
printf!("%d ", i) // prints "0 1 2 3 4 5"
209+
print!("{} ", i) // prints "0 1 2 3 4 5"
205210
}
206211
~~~
207212
@@ -233,15 +238,15 @@ let mut it = xs.iter().zip(ys.iter());
233238

234239
// print out the pairs of elements up to (&3, &"baz")
235240
for (x, y) in it {
236-
printfln!("%d %s", *x, *y);
241+
println!("{} {}", *x, *y);
237242

238243
if *x == 3 {
239244
break;
240245
}
241246
}
242247

243248
// yield and print the last pair from the iterator
244-
printfln!("last: %?", it.next());
249+
println!("last: {:?}", it.next());
245250

246251
// the iterator is now fully consumed
247252
assert!(it.next().is_none());
@@ -335,13 +340,13 @@ another `DoubleEndedIterator` with `next` and `next_back` exchanged.
335340
~~~
336341
let xs = [1, 2, 3, 4, 5, 6];
337342
let mut it = xs.iter();
338-
printfln!("%?", it.next()); // prints `Some(&1)`
339-
printfln!("%?", it.next()); // prints `Some(&2)`
340-
printfln!("%?", it.next_back()); // prints `Some(&6)`
343+
println!("{:?}", it.next()); // prints `Some(&1)`
344+
println!("{:?}", it.next()); // prints `Some(&2)`
345+
println!("{:?}", it.next_back()); // prints `Some(&6)`
341346
342347
// prints `5`, `4` and `3`
343348
for &x in it.invert() {
344-
printfln!("%?", x)
349+
println!("{}", x)
345350
}
346351
~~~
347352

@@ -356,11 +361,11 @@ let xs = [1, 2, 3, 4];
356361
let ys = [5, 6, 7, 8];
357362
let mut it = xs.iter().chain(ys.iter()).map(|&x| x * 2);
358363
359-
printfln!("%?", it.next()); // prints `Some(2)`
364+
println!("{:?}", it.next()); // prints `Some(2)`
360365
361366
// prints `16`, `14`, `12`, `10`, `8`, `6`, `4`
362367
for x in it.invert() {
363-
printfln!("%?", x);
368+
println!("{}", x);
364369
}
365370
~~~
366371

@@ -387,17 +392,17 @@ underlying iterators are.
387392
let xs = [1, 2, 3, 4, 5];
388393
let ys = ~[7, 9, 11];
389394
let mut it = xs.iter().chain(ys.iter());
390-
printfln!("%?", it.idx(0)); // prints `Some(&1)`
391-
printfln!("%?", it.idx(5)); // prints `Some(&7)`
392-
printfln!("%?", it.idx(7)); // prints `Some(&11)`
393-
printfln!("%?", it.idx(8)); // prints `None`
395+
println!("{:?}", it.idx(0)); // prints `Some(&1)`
396+
println!("{:?}", it.idx(5)); // prints `Some(&7)`
397+
println!("{:?}", it.idx(7)); // prints `Some(&11)`
398+
println!("{:?}", it.idx(8)); // prints `None`
394399
395400
// yield two elements from the beginning, and one from the end
396401
it.next();
397402
it.next();
398403
it.next_back();
399404
400-
printfln!("%?", it.idx(0)); // prints `Some(&3)`
401-
printfln!("%?", it.idx(4)); // prints `Some(&9)`
402-
printfln!("%?", it.idx(6)); // prints `None`
405+
println!("{:?}", it.idx(0)); // prints `Some(&3)`
406+
println!("{:?}", it.idx(4)); // prints `Some(&9)`
407+
println!("{:?}", it.idx(6)); // prints `None`
403408
~~~

doc/tutorial.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2979,15 +2979,15 @@ tutorials on individual topics.
29792979
* [The foreign function interface][ffi]
29802980
* [Containers and iterators](tutorial-container.html)
29812981
* [Error-handling and Conditions](tutorial-conditions.html)
2982-
* [Packaging up Rust code](rustpkg)
2982+
* [Packaging up Rust code][rustpkg]
29832983

29842984
There is further documentation on the [wiki], however those tend to be even more out of date as this document.
29852985

29862986
[borrow]: tutorial-borrowed-ptr.html
29872987
[tasks]: tutorial-tasks.html
29882988
[macros]: tutorial-macros.html
29892989
[ffi]: tutorial-ffi.html
2990-
[rustpkg]: tutorial-rustpkg.html
2990+
[rustpkg]: rustpkg.html
29912991

29922992
[wiki]: https://github.com/mozilla/rust/wiki/Docs
29932993

0 commit comments

Comments
 (0)