Skip to content

Guide iterators #16887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
414 changes: 3 additions & 411 deletions src/doc/guide-container.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ a guide that can help you out:
* [Strings](guide-strings.html)
* [Pointers](guide-pointers.html)
* [References and Lifetimes](guide-lifetimes.html)
* [Containers and Iterators](guide-container.html)
* [Tasks and Communication](guide-tasks.html)
* [Foreign Function Interface](guide-ffi.html)
* [Writing Unsafe and Low-Level Code](guide-unsafe.html)
Expand Down
5 changes: 5 additions & 0 deletions src/libcollections/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

//! A priority queue implemented with a binary heap.
//!
//! Insertions have `O(log n)` time complexity and checking or popping the largest element is
//! `O(1)`. Converting a vector to a priority queue can be done in-place, and has `O(n)`
//! complexity. A priority queue can also be converted to a sorted vector in-place, allowing it to
//! be used for an `O(n log n)` in-place heapsort.
//!
//! # Example
//!
//! This is a larger example which implements [Dijkstra's algorithm][dijkstra]
Expand Down
8 changes: 4 additions & 4 deletions src/libcollections/ringbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! A double-ended queue implemented as a circular buffer.
//!
//! `RingBuf` implements the trait `Deque`. It should be imported with
//! `use collections::Deque`.
//! This crate implements a double-ended queue with `O(1)` amortized inserts and removals from both
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line must be really close to 100, if it's not over.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I let vim handle such things, maybe I should double check.

//! ends of the container. It also has `O(1)` indexing like a vector. The contained elements are
//! not required to be copyable, and the queue will be sendable if the contained type is sendable.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of interest, why did you keep these copyable and sendable comments only for deque?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there another place it should be too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the original page has it for multiple types:

I was just wondering if there was a reason that only deque had this snippet transferred.

I don't actually think we should bother mentioning these for each type; just have a general section in the main docs about this sort of basic type requirement/implication with only the exceptions with an explicit note like this.

(i.e. almost all the basic collections have unique ownership & inherited mutability and are careful with their contents, and thus satisfy these properties. Being nonsendable or requiring copy is the 'surprising' case.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh. I was looking in the wrong place, because that paragraph comes form here: https://github.com/rust-lang/rust/pull/16887/files#diff-cc3af746394f582ee863741589439e75L45

I don't remember specifically why, may even just be my own error.

//! Its interface `Deque` is defined in `collections`.

use core::prelude::*;

Expand Down
10 changes: 7 additions & 3 deletions src/libcollections/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! An ordered map and set implemented as self-balancing binary search
//! trees. The only requirement for the types is that the key implements
//! `Ord`.
//! Maps are collections of unique keys with corresponding values, and sets are
//! just unique keys without a corresponding value. The `Map` and `Set` traits in
//! `std::container` define the basic interface.
//!
//! This crate defines the `TreeMap` and `TreeSet` types. Their keys must implement `Ord`.
//!
//! `TreeMap`s are ordered.
//!
//! ## Example
//!
Expand Down
9 changes: 7 additions & 2 deletions src/libcollections/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Ordered containers with unsigned integer keys,
//! implemented as radix tries (`TrieSet` and `TrieMap` types).
//! Maps are collections of unique keys with corresponding values, and sets are
//! just unique keys without a corresponding value. The `Map` and `Set` traits in
//! `std::container` define the basic interface.
//!
//! This crate defines `TrieMap` and `TrieSet`, which require `uint` keys.
//!
//! `TrieMap` is ordered.

use core::prelude::*;

Expand Down
4 changes: 3 additions & 1 deletion src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! An owned, growable vector.
//! A growable list type, written `Vec<T>` but pronounced 'vector.'
//!
//! Vectors have `O(1)` indexing, push (to the end) and pop (from the end).

use core::prelude::*;

Expand Down
6 changes: 0 additions & 6 deletions src/libcore/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ loop {

This `for` loop syntax can be applied to any iterator over any type.

## Iteration protocol and more

More detailed information about iterators can be found in the [container
guide](http://doc.rust-lang.org/guide-container.html) with
the rest of the rust manuals.

*/

use clone::Clone;
Expand Down