Skip to content

Commit cd1d4a8

Browse files
committed
---
yaml --- r: 125806 b: refs/heads/try c: c080d26 h: refs/heads/master v: v3
1 parent 30f0fe7 commit cd1d4a8

File tree

20 files changed

+602
-285
lines changed

20 files changed

+602
-285
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: f2fa55903e378368ed9173560f03a0ef16e371c2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 9fc8394d3bce22ab483f98842434c84c396212ae
5-
refs/heads/try: 366c66e171b94ef78ce7b8daf2530dbdc30eadb9
5+
refs/heads/try: c080d26d328d6e8bbf4b159b5c5f3cd55c86f621
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/doc/guide.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -624,15 +624,10 @@ let x = (let y = 5i); // found `let` in ident position
624624
The compiler is telling us here that it was expecting to see the beginning of
625625
an expression, and a `let` can only begin a statement, not an expression.
626626

627-
However, assigning to a variable binding is an expression:
628-
629-
```{rust}
630-
let x;
631-
let y = x = 5i;
632-
```
633-
634-
In this case, we have an assignment expression (`x = 5`) whose value is
635-
being used as part of a `let` declaration statement (`let y = ...`).
627+
Note that assigning to an already-bound variable (e.g. `y = 5i`) is still an
628+
expression, although its value is not particularly useful. Unlike C, where an
629+
assignment evaluates to the assigned value (e.g. `5i` in the previous example),
630+
in Rust the value of an assignment is the unit type `()` (which we'll cover later).
636631

637632
The second kind of statement in Rust is the **expression statement**. Its
638633
purpose is to turn any expression into a statement. In practical terms, Rust's

branches/try/src/libcollections/treemap.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -190,33 +190,38 @@ impl<K: Ord, V> TreeMap<K, V> {
190190
}
191191

192192
impl<K, V> TreeMap<K, V> {
193-
/// Return the value for which f(key) returns Equal. f is invoked
194-
/// with current key and helps to navigate the tree
193+
/// Return the value for which `f(key)` returns `Equal`. `f` is invoked
194+
/// with current key and guides tree navigation. That means `f` should
195+
/// be aware of natural ordering of the tree.
195196
///
196197
/// # Example
197198
///
198199
/// ```
199-
/// use std::ascii::StrAsciiExt;
200+
/// use collections::treemap::TreeMap;
200201
///
201-
/// let mut t = collections::treemap::TreeMap::new();
202-
/// t.insert("Content-Type", "application/xml");
203-
/// t.insert("User-Agent", "Curl-Rust/0.1");
202+
/// fn get_headers() -> TreeMap<String, String> {
203+
/// let mut result = TreeMap::new();
204+
/// result.insert("Content-Type".to_string(), "application/xml".to_string());
205+
/// result.insert("User-Agent".to_string(), "Curl-Rust/0.1".to_string());
206+
/// result
207+
/// }
204208
///
205-
/// let ua_key = "user-agent";
206-
/// let ua = t.find_with(|&k| {
207-
/// ua_key.cmp(&k.to_ascii_lower().as_slice())
209+
/// let headers = get_headers();
210+
/// let ua_key = "User-Agent";
211+
/// let ua = headers.find_with(|k| {
212+
/// ua_key.cmp(&k.as_slice())
208213
/// });
209214
///
210-
/// assert_eq!(*ua.unwrap(), "Curl-Rust/0.1");
215+
/// assert_eq!((*ua.unwrap()).as_slice(), "Curl-Rust/0.1");
211216
/// ```
212217
#[inline]
213218
pub fn find_with<'a>(&'a self, f:|&K| -> Ordering) -> Option<&'a V> {
214219
tree_find_with(&self.root, f)
215220
}
216221

217-
/// Return the value for which f(key) returns Equal. f is invoked
218-
/// with current key and helps to navigate the tree
219-
///
222+
/// Return the value for which `f(key)` returns `Equal`. `f` is invoked
223+
/// with current key and guides tree navigation. That means `f` should
224+
/// be aware of natural ordering of the tree.
220225
/// # Example
221226
///
222227
/// ```
@@ -913,14 +918,9 @@ fn split<K: Ord, V>(node: &mut Box<TreeNode<K, V>>) {
913918
}
914919
}
915920

916-
// Next 2 functions have the same conventions
917-
//
918-
// The only difference is that non-mutable version uses loop instead
919-
// of recursion (performance considerations)
920-
// It seems to be impossible to avoid recursion with mutability
921-
//
922-
// So convention is that comparator is gets at input current key
923-
// and returns search_key cmp cur_key (i.e. search_key.cmp(cur_key))
921+
// Next 2 functions have the same convention: comparator gets
922+
// at input current key and returns search_key cmp cur_key
923+
// (i.e. search_key.cmp(&cur_key))
924924
fn tree_find_with<'r, K, V>(node: &'r Option<Box<TreeNode<K, V>>>,
925925
f: |&K| -> Ordering) -> Option<&'r V> {
926926
let mut current: &'r Option<Box<TreeNode<K, V>>> = node;

0 commit comments

Comments
 (0)