diff options
| author | T-O-R-U-S <bageliq@protonmail.com> | 2022-02-12 23:16:17 +0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-03-10 10:23:40 -0500 |
| commit | 72a25d05bf1a4b155d74139ef700ff93af6d8e22 (patch) | |
| tree | 3f143b29a3a51b68e9b29d93e47fb0b0968ad3df /library/alloc/src/collections | |
| parent | ba14a836c7038da21f5e102aacc7e6d5964f79a6 (diff) | |
| download | rust-72a25d05bf1a4b155d74139ef700ff93af6d8e22.tar.gz rust-72a25d05bf1a4b155d74139ef700ff93af6d8e22.zip | |
Use implicit capture syntax in format_args
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
Diffstat (limited to 'library/alloc/src/collections')
| -rw-r--r-- | library/alloc/src/collections/binary_heap.rs | 10 | ||||
| -rw-r--r-- | library/alloc/src/collections/btree/map.rs | 12 | ||||
| -rw-r--r-- | library/alloc/src/collections/btree/map/tests.rs | 2 | ||||
| -rw-r--r-- | library/alloc/src/collections/btree/set.rs | 4 | ||||
| -rw-r--r-- | library/alloc/src/collections/btree/set/tests.rs | 6 |
5 files changed, 17 insertions, 17 deletions
diff --git a/library/alloc/src/collections/binary_heap.rs b/library/alloc/src/collections/binary_heap.rs index e18cd8cd464..43fa612de6c 100644 --- a/library/alloc/src/collections/binary_heap.rs +++ b/library/alloc/src/collections/binary_heap.rs @@ -194,7 +194,7 @@ use super::SpecExtend; /// // We can iterate over the items in the heap, although they are returned in /// // a random order. /// for x in &heap { -/// println!("{}", x); +/// println!("{x}"); /// } /// /// // If we instead pop these scores, they should come back in order. @@ -830,7 +830,7 @@ impl<T> BinaryHeap<T> { /// /// // Print 1, 2, 3, 4 in arbitrary order /// for x in heap.iter() { - /// println!("{}", x); + /// println!("{x}"); /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -1110,7 +1110,7 @@ impl<T> BinaryHeap<T> { /// /// // Will print in some order /// for x in vec { - /// println!("{}", x); + /// println!("{x}"); /// } /// ``` #[must_use = "`self` will be dropped if the result is not used"] @@ -1179,7 +1179,7 @@ impl<T> BinaryHeap<T> { /// assert!(!heap.is_empty()); /// /// for x in heap.drain() { - /// println!("{}", x); + /// println!("{x}"); /// } /// /// assert!(heap.is_empty()); @@ -1624,7 +1624,7 @@ impl<T> IntoIterator for BinaryHeap<T> { /// // Print 1, 2, 3, 4 in arbitrary order /// for x in heap.into_iter() { /// // x has type i32, not &i32 - /// println!("{}", x); + /// println!("{x}"); /// } /// ``` fn into_iter(self) -> IntoIter<T> { diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index 7890c1040f0..6d00642e03b 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -104,8 +104,8 @@ pub(super) const MIN_LEN: usize = node::MIN_LEN_AFTER_SPLIT; /// let to_find = ["Up!", "Office Space"]; /// for movie in &to_find { /// match movie_reviews.get(movie) { -/// Some(review) => println!("{}: {}", movie, review), -/// None => println!("{} is unreviewed.", movie) +/// Some(review) => println!("{movie}: {review}"), +/// None => println!("{movie} is unreviewed.") /// } /// } /// @@ -114,7 +114,7 @@ pub(super) const MIN_LEN: usize = node::MIN_LEN_AFTER_SPLIT; /// /// // iterate over everything. /// for (movie, review) in &movie_reviews { -/// println!("{}: \"{}\"", movie, review); +/// println!("{movie}: \"{review}\""); /// } /// ``` /// @@ -1061,7 +1061,7 @@ impl<K, V> BTreeMap<K, V> { /// map.insert(5, "b"); /// map.insert(8, "c"); /// for (&key, &value) in map.range((Included(&4), Included(&8))) { - /// println!("{}: {}", key, value); + /// println!("{key}: {value}"); /// } /// assert_eq!(Some((&5, &"b")), map.range(4..).next()); /// ``` @@ -1104,7 +1104,7 @@ impl<K, V> BTreeMap<K, V> { /// *balance += 100; /// } /// for (name, balance) in &map { - /// println!("{} => {}", name, balance); + /// println!("{name} => {balance}"); /// } /// ``` #[stable(feature = "btree_range", since = "1.17.0")] @@ -2088,7 +2088,7 @@ impl<K, V> BTreeMap<K, V> { /// map.insert(1, "a"); /// /// for (key, value) in map.iter() { - /// println!("{}: {}", key, value); + /// println!("{key}: {value}"); /// } /// /// let (first_key, first_value) = map.iter().next().unwrap(); diff --git a/library/alloc/src/collections/btree/map/tests.rs b/library/alloc/src/collections/btree/map/tests.rs index 65468d5fe57..4d21df32417 100644 --- a/library/alloc/src/collections/btree/map/tests.rs +++ b/library/alloc/src/collections/btree/map/tests.rs @@ -1758,7 +1758,7 @@ fn test_ord_absence() { } fn map_debug<K: Debug>(mut map: BTreeMap<K, ()>) { - format!("{:?}", map); + format!("{map:?}"); format!("{:?}", map.iter()); format!("{:?}", map.iter_mut()); format!("{:?}", map.keys()); diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index bab6af82698..405833720b3 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -60,7 +60,7 @@ use super::Recover; /// /// // Iterate over everything. /// for book in &books { -/// println!("{}", book); +/// println!("{book}"); /// } /// ``` /// @@ -284,7 +284,7 @@ impl<T> BTreeSet<T> { /// set.insert(5); /// set.insert(8); /// for &elem in set.range((Included(&4), Included(&8))) { - /// println!("{}", elem); + /// println!("{elem}"); /// } /// assert_eq!(Some(&5), set.range(4..).next()); /// ``` diff --git a/library/alloc/src/collections/btree/set/tests.rs b/library/alloc/src/collections/btree/set/tests.rs index 7865d37ae51..032563e4f09 100644 --- a/library/alloc/src/collections/btree/set/tests.rs +++ b/library/alloc/src/collections/btree/set/tests.rs @@ -431,10 +431,10 @@ fn test_show() { set.insert(1); set.insert(2); - let set_str = format!("{:?}", set); + let set_str = format!("{set:?}"); assert_eq!(set_str, "{1, 2}"); - assert_eq!(format!("{:?}", empty), "{}"); + assert_eq!(format!("{empty:?}"), "{}"); } #[test] @@ -649,7 +649,7 @@ fn test_ord_absence() { } fn set_debug<K: Debug>(set: BTreeSet<K>) { - format!("{:?}", set); + format!("{set:?}"); format!("{:?}", set.iter()); format!("{:?}", set.into_iter()); } |
