diff options
Diffstat (limited to 'library/alloc')
23 files changed, 82 insertions, 82 deletions
diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index 9d4f9af91a5..bd7d721b5e1 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -397,7 +397,7 @@ pub mod __alloc_error_handler { // if there is no `#[alloc_error_handler]` #[rustc_std_internal_symbol] pub unsafe extern "C-unwind" fn __rdl_oom(size: usize, _align: usize) -> ! { - panic!("memory allocation of {} bytes failed", size) + panic!("memory allocation of {size} bytes failed") } // if there is an `#[alloc_error_handler]` diff --git a/library/alloc/src/borrow.rs b/library/alloc/src/borrow.rs index 63234ee91f0..8b13e36c4b3 100644 --- a/library/alloc/src/borrow.rs +++ b/library/alloc/src/borrow.rs @@ -161,7 +161,7 @@ where /// let readonly = [1, 2]; /// let borrowed = Items::new((&readonly[..]).into()); /// match borrowed { -/// Items { values: Cow::Borrowed(b) } => println!("borrowed {:?}", b), +/// Items { values: Cow::Borrowed(b) } => println!("borrowed {b:?}"), /// _ => panic!("expect borrowed value"), /// } /// diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 68bf59a01b3..6b5b73740e1 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -31,7 +31,7 @@ //! } //! //! let list: List<i32> = List::Cons(1, Box::new(List::Cons(2, Box::new(List::Nil)))); -//! println!("{:?}", list); +//! println!("{list:?}"); //! ``` //! //! This will print `Cons(1, Cons(2, Nil))`. @@ -1408,7 +1408,7 @@ impl<T: Copy> From<&[T]> for Box<[T]> { /// let slice: &[u8] = &[104, 101, 108, 108, 111]; /// let boxed_slice: Box<[u8]> = Box::from(slice); /// - /// println!("{:?}", boxed_slice); + /// println!("{boxed_slice:?}"); /// ``` fn from(slice: &[T]) -> Box<[T]> { let len = slice.len(); @@ -1450,7 +1450,7 @@ impl From<&str> for Box<str> { /// /// ```rust /// let boxed: Box<str> = Box::from("hello"); - /// println!("{}", boxed); + /// println!("{boxed}"); /// ``` #[inline] fn from(s: &str) -> Box<str> { @@ -1475,14 +1475,14 @@ impl From<Cow<'_, str>> for Box<str> { /// /// let unboxed = Cow::Borrowed("hello"); /// let boxed: Box<str> = Box::from(unboxed); - /// println!("{}", boxed); + /// println!("{boxed}"); /// ``` /// /// ```rust /// # use std::borrow::Cow; /// let unboxed = Cow::Owned("hello".to_string()); /// let boxed: Box<str> = Box::from(unboxed); - /// println!("{}", boxed); + /// println!("{boxed}"); /// ``` #[inline] fn from(cow: Cow<'_, str>) -> Box<str> { @@ -1529,7 +1529,7 @@ impl<T, const N: usize> From<[T; N]> for Box<[T]> { /// /// ```rust /// let boxed: Box<[u8]> = Box::from([4, 2]); - /// println!("{:?}", boxed); + /// println!("{boxed:?}"); /// ``` fn from(array: [T; N]) -> Box<[T]> { box array 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()); } diff --git a/library/alloc/src/fmt.rs b/library/alloc/src/fmt.rs index aeb7554f8e9..501a6353b2c 100644 --- a/library/alloc/src/fmt.rs +++ b/library/alloc/src/fmt.rs @@ -416,9 +416,9 @@ //! fn main() { //! let myvector = Vector2D { x: 3, y: 4 }; //! -//! println!("{}", myvector); // => "(3, 4)" -//! println!("{:?}", myvector); // => "Vector2D {x: 3, y:4}" -//! println!("{:10.3b}", myvector); // => " 5.000" +//! println!("{myvector}"); // => "(3, 4)" +//! println!("{myvector:?}"); // => "Vector2D {x: 3, y:4}" +//! println!("{myvector:10.3b}"); // => " 5.000" //! } //! ``` //! diff --git a/library/alloc/src/rc/tests.rs b/library/alloc/src/rc/tests.rs index 843a9b07fa9..d7c28f80633 100644 --- a/library/alloc/src/rc/tests.rs +++ b/library/alloc/src/rc/tests.rs @@ -309,7 +309,7 @@ fn test_cowrc_clone_weak() { #[test] fn test_show() { let foo = Rc::new(75); - assert_eq!(format!("{:?}", foo), "75"); + assert_eq!(format!("{foo:?}"), "75"); } #[test] @@ -324,7 +324,7 @@ fn test_maybe_thin_unsized() { use std::ffi::{CStr, CString}; let x: Rc<CStr> = Rc::from(CString::new("swordfish").unwrap().into_boxed_c_str()); - assert_eq!(format!("{:?}", x), "\"swordfish\""); + assert_eq!(format!("{x:?}"), "\"swordfish\""); let y: Weak<CStr> = Rc::downgrade(&x); drop(x); @@ -451,7 +451,7 @@ fn test_from_box_trait_zero_sized() { let b: Box<dyn Debug> = box (); let r: Rc<dyn Debug> = Rc::from(b); - assert_eq!(format!("{:?}", r), "()"); + assert_eq!(format!("{r:?}"), "()"); } #[test] diff --git a/library/alloc/src/slice.rs b/library/alloc/src/slice.rs index f0397d08f95..f52871c73d9 100644 --- a/library/alloc/src/slice.rs +++ b/library/alloc/src/slice.rs @@ -48,7 +48,7 @@ //! ``` //! let numbers = &[0, 1, 2]; //! for n in numbers { -//! println!("{} is a number!", n); +//! println!("{n} is a number!"); //! } //! ``` //! diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 716bb4983a6..71419c15196 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -2718,7 +2718,7 @@ impl From<String> for Vec<u8> { /// let v1 = Vec::from(s1); /// /// for b in v1 { - /// println!("{}", b); + /// println!("{b}"); /// } /// ``` fn from(string: String) -> Vec<u8> { diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 7e7670aad64..2140c3f168d 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -200,7 +200,7 @@ macro_rules! acquire { /// let five = Arc::clone(&five); /// /// thread::spawn(move || { -/// println!("{:?}", five); +/// println!("{five:?}"); /// }); /// } /// ``` @@ -221,7 +221,7 @@ macro_rules! acquire { /// /// thread::spawn(move || { /// let v = val.fetch_add(1, Ordering::SeqCst); -/// println!("{:?}", v); +/// println!("{v:?}"); /// }); /// } /// ``` diff --git a/library/alloc/src/sync/tests.rs b/library/alloc/src/sync/tests.rs index 4ccb32fbbf6..452a8877301 100644 --- a/library/alloc/src/sync/tests.rs +++ b/library/alloc/src/sync/tests.rs @@ -335,7 +335,7 @@ fn test_weak_count() { #[test] fn show_arc() { let a = Arc::new(5); - assert_eq!(format!("{:?}", a), "5"); + assert_eq!(format!("{a:?}"), "5"); } // Make sure deriving works with Arc<T> @@ -347,7 +347,7 @@ struct Foo { #[test] fn test_unsized() { let x: Arc<[i32]> = Arc::new([1, 2, 3]); - assert_eq!(format!("{:?}", x), "[1, 2, 3]"); + assert_eq!(format!("{x:?}"), "[1, 2, 3]"); let y = Arc::downgrade(&x.clone()); drop(x); assert!(y.upgrade().is_none()); @@ -359,7 +359,7 @@ fn test_maybe_thin_unsized() { use std::ffi::{CStr, CString}; let x: Arc<CStr> = Arc::from(CString::new("swordfish").unwrap().into_boxed_c_str()); - assert_eq!(format!("{:?}", x), "\"swordfish\""); + assert_eq!(format!("{x:?}"), "\"swordfish\""); let y: Weak<CStr> = Arc::downgrade(&x); drop(x); @@ -509,7 +509,7 @@ fn test_from_box_trait_zero_sized() { let b: Box<dyn Debug> = box (); let r: Arc<dyn Debug> = Arc::from(b); - assert_eq!(format!("{:?}", r), "()"); + assert_eq!(format!("{r:?}"), "()"); } #[test] diff --git a/library/alloc/src/tests.rs b/library/alloc/src/tests.rs index b4741c35c58..299ed156a5d 100644 --- a/library/alloc/src/tests.rs +++ b/library/alloc/src/tests.rs @@ -47,8 +47,8 @@ fn any_move() { fn test_show() { let a = Box::new(8) as Box<dyn Any>; let b = Box::new(Test) as Box<dyn Any>; - let a_str = format!("{:?}", a); - let b_str = format!("{:?}", b); + let a_str = format!("{a:?}"); + let b_str = format!("{b:?}"); assert_eq!(a_str, "Any { .. }"); assert_eq!(b_str, "Any { .. }"); @@ -56,9 +56,9 @@ fn test_show() { static TEST: Test = Test; let a = &EIGHT as &dyn Any; let b = &TEST as &dyn Any; - let s = format!("{:?}", a); + let s = format!("{a:?}"); assert_eq!(s, "Any { .. }"); - let s = format!("{:?}", b); + let s = format!("{b:?}"); assert_eq!(s, "Any { .. }"); } diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index c4c393f55ee..32590a2996c 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -169,7 +169,7 @@ mod spec_extend; /// vec.extend([1, 2, 3].iter().copied()); /// /// for x in &vec { -/// println!("{}", x); +/// println!("{x}"); /// } /// assert_eq!(vec, [7, 1, 2, 3]); /// ``` @@ -211,7 +211,7 @@ mod spec_extend; /// /// while let Some(top) = stack.pop() { /// // Prints 3, 2, 1 -/// println!("{}", top); +/// println!("{top}"); /// } /// ``` /// @@ -1297,7 +1297,7 @@ impl<T, A: Allocator> Vec<T, A> { #[cold] #[inline(never)] fn assert_failed(index: usize, len: usize) -> ! { - panic!("swap_remove index (is {}) should be < len (is {})", index, len); + panic!("swap_remove index (is {index}) should be < len (is {len})"); } let len = self.len(); @@ -1338,7 +1338,7 @@ impl<T, A: Allocator> Vec<T, A> { #[cold] #[inline(never)] fn assert_failed(index: usize, len: usize) -> ! { - panic!("insertion index (is {}) should be <= len (is {})", index, len); + panic!("insertion index (is {index}) should be <= len (is {len})"); } let len = self.len(); @@ -1397,7 +1397,7 @@ impl<T, A: Allocator> Vec<T, A> { #[inline(never)] #[track_caller] fn assert_failed(index: usize, len: usize) -> ! { - panic!("removal index (is {}) should be < len (is {})", index, len); + panic!("removal index (is {index}) should be < len (is {len})"); } let len = self.len(); @@ -1942,7 +1942,7 @@ impl<T, A: Allocator> Vec<T, A> { #[cold] #[inline(never)] fn assert_failed(at: usize, len: usize) -> ! { - panic!("`at` split index (is {}) should be <= len (is {})", at, len); + panic!("`at` split index (is {at}) should be <= len (is {len})"); } if at > self.len() { @@ -2568,7 +2568,7 @@ impl<T, A: Allocator> IntoIterator for Vec<T, A> { /// let v = vec!["a".to_string(), "b".to_string()]; /// for s in v.into_iter() { /// // s has type String, not &String - /// println!("{}", s); + /// println!("{s}"); /// } /// ``` #[inline] diff --git a/library/alloc/tests/fmt.rs b/library/alloc/tests/fmt.rs index 27ab6c07e43..1575a5999f9 100644 --- a/library/alloc/tests/fmt.rs +++ b/library/alloc/tests/fmt.rs @@ -84,8 +84,8 @@ fn test_format_macro_interface() { } t!(format!("{:p}", 0x1234 as *const isize), "0x1234"); t!(format!("{:p}", 0x1234 as *mut isize), "0x1234"); - t!(format!("{:x}", A), "aloha"); - t!(format!("{:X}", B), "adios"); + t!(format!("{A:x}"), "aloha"); + t!(format!("{B:X}"), "adios"); t!(format!("foo {} ☃☃☃☃☃☃", "bar"), "foo bar ☃☃☃☃☃☃"); t!(format!("{1} {0}", 0, 1), "1 0"); t!(format!("{foo} {bar}", foo = 0, bar = 1), "0 1"); @@ -94,11 +94,11 @@ fn test_format_macro_interface() { t!(format!("{_foo}", _foo = 6usize), "6"); t!(format!("{foo_bar}", foo_bar = 1), "1"); t!(format!("{}", 5 + 5), "10"); - t!(format!("{:#4}", C), "☃123"); - t!(format!("{:b}", D), "aa☃bb"); + t!(format!("{C:#4}"), "☃123"); + t!(format!("{D:b}"), "aa☃bb"); let a: &dyn fmt::Debug = &1; - t!(format!("{:?}", a), "1"); + t!(format!("{a:?}"), "1"); // Formatting strings and their arguments t!(format!("{}", "a"), "a"); @@ -206,7 +206,7 @@ fn test_format_macro_interface() { // Test that pointers don't get truncated. { let val = usize::MAX; - let exp = format!("{:#x}", val); + let exp = format!("{val:#x}"); t!(format!("{:p}", val as *const isize), exp); } @@ -216,14 +216,14 @@ fn test_format_macro_interface() { // make sure that format! doesn't move out of local variables let a = Box::new(3); - format!("{}", a); - format!("{}", a); + format!("{a}"); + format!("{a}"); // make sure that format! doesn't cause spurious unused-unsafe warnings when // it's inside of an outer unsafe block unsafe { let a: isize = ::std::mem::transmute(3_usize); - format!("{}", a); + format!("{a}"); } // test that trailing commas are acceptable @@ -315,9 +315,9 @@ fn test_once() { #[test] fn test_refcell() { let refcell = RefCell::new(5); - assert_eq!(format!("{:?}", refcell), "RefCell { value: 5 }"); + assert_eq!(format!("{refcell:?}"), "RefCell { value: 5 }"); let borrow = refcell.borrow_mut(); - assert_eq!(format!("{:?}", refcell), "RefCell { value: <borrowed> }"); + assert_eq!(format!("{refcell:?}"), "RefCell { value: <borrowed> }"); drop(borrow); - assert_eq!(format!("{:?}", refcell), "RefCell { value: 5 }"); + assert_eq!(format!("{refcell:?}"), "RefCell { value: 5 }"); } diff --git a/library/alloc/tests/linked_list.rs b/library/alloc/tests/linked_list.rs index 5f5bd9af2fe..66a9cca6644 100644 --- a/library/alloc/tests/linked_list.rs +++ b/library/alloc/tests/linked_list.rs @@ -302,10 +302,10 @@ fn test_ord_nan() { #[test] fn test_show() { let list: LinkedList<_> = (0..10).collect(); - assert_eq!(format!("{:?}", list), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"); + assert_eq!(format!("{list:?}"), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"); let list: LinkedList<_> = ["just", "one", "test", "more"].into_iter().collect(); - assert_eq!(format!("{:?}", list), "[\"just\", \"one\", \"test\", \"more\"]"); + assert_eq!(format!("{list:?}"), "[\"just\", \"one\", \"test\", \"more\"]"); } #[test] diff --git a/library/alloc/tests/slice.rs b/library/alloc/tests/slice.rs index b93d7938bc9..b027a25a146 100644 --- a/library/alloc/tests/slice.rs +++ b/library/alloc/tests/slice.rs @@ -1045,10 +1045,10 @@ fn test_split_iterators_size_hint() { a(v.rsplit_mut(p), b, "rsplit_mut"); for n in 0..=3 { - a(v.splitn(n, p), b, f!("splitn, n = {}", n)); - a(v.splitn_mut(n, p), b, f!("splitn_mut, n = {}", n)); - a(v.rsplitn(n, p), b, f!("rsplitn, n = {}", n)); - a(v.rsplitn_mut(n, p), b, f!("rsplitn_mut, n = {}", n)); + a(v.splitn(n, p), b, f!("splitn, n = {n}")); + a(v.splitn_mut(n, p), b, f!("splitn_mut, n = {n}")); + a(v.rsplitn(n, p), b, f!("rsplitn, n = {n}")); + a(v.rsplitn_mut(n, p), b, f!("rsplitn_mut, n = {n}")); } } } @@ -1184,8 +1184,8 @@ fn test_show() { macro_rules! test_show_vec { ($x:expr, $x_str:expr) => {{ let (x, x_str) = ($x, $x_str); - assert_eq!(format!("{:?}", x), x_str); - assert_eq!(format!("{:?}", x), x_str); + assert_eq!(format!("{x:?}"), x_str); + assert_eq!(format!("{x:?}"), x_str); }}; } let empty = Vec::<i32>::new(); diff --git a/library/alloc/tests/str.rs b/library/alloc/tests/str.rs index 6b8be2506b6..f3ed611acda 100644 --- a/library/alloc/tests/str.rs +++ b/library/alloc/tests/str.rs @@ -1259,7 +1259,7 @@ fn test_chars_debug() { let s = "ศไทย中华Việt Nam"; let c = s.chars(); assert_eq!( - format!("{:?}", c), + format!("{c:?}"), r#"Chars(['ศ', 'ไ', 'ท', 'ย', '中', '华', 'V', 'i', 'ệ', 't', ' ', 'N', 'a', 'm'])"# ); } @@ -1870,7 +1870,7 @@ mod pattern { } if let Some(err) = err { - panic!("Input skipped range at {}", err); + panic!("Input skipped range at {err}"); } if first_index != haystack.len() { @@ -2187,10 +2187,10 @@ fn utf8() { fn check_str_eq(a: String, b: String) { let mut i: isize = 0; for ab in a.bytes() { - println!("{}", i); - println!("{}", ab); + println!("{i}"); + println!("{ab}"); let bb: u8 = b.as_bytes()[i as usize]; - println!("{}", bb); + println!("{bb}"); assert_eq!(ab, bb); i += 1; } diff --git a/library/alloc/tests/string.rs b/library/alloc/tests/string.rs index 893283e5a24..b6836fdc88e 100644 --- a/library/alloc/tests/string.rs +++ b/library/alloc/tests/string.rs @@ -470,7 +470,7 @@ fn test_simple_types() { #[test] fn test_vectors() { let x: Vec<i32> = vec![]; - assert_eq!(format!("{:?}", x), "[]"); + assert_eq!(format!("{x:?}"), "[]"); assert_eq!(format!("{:?}", vec![1]), "[1]"); assert_eq!(format!("{:?}", vec![1, 2, 3]), "[1, 2, 3]"); assert!(format!("{:?}", vec![vec![], vec![1], vec![1, 1]]) == "[[], [1], [1, 1]]"); @@ -871,6 +871,6 @@ fn test_from_char() { fn test_str_concat() { let a: String = "hello".to_string(); let b: String = "world".to_string(); - let s: String = format!("{}{}", a, b); + let s: String = format!("{a}{b}"); assert_eq!(s.as_bytes()[9], 'd' as u8); } diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs index 705914b4497..ca0fcc855c7 100644 --- a/library/alloc/tests/vec.rs +++ b/library/alloc/tests/vec.rs @@ -100,7 +100,7 @@ fn test_debug_fmt() { assert_eq!("[0, 1]", format!("{:?}", vec2)); let slice: &[isize] = &[4, 5]; - assert_eq!("[4, 5]", format!("{:?}", slice)); + assert_eq!("[4, 5]", format!("{slice:?}")); } #[test] @@ -918,7 +918,7 @@ fn test_into_iter_as_mut_slice() { fn test_into_iter_debug() { let vec = vec!['a', 'b', 'c']; let into_iter = vec.into_iter(); - let debug = format!("{:?}", into_iter); + let debug = format!("{into_iter:?}"); assert_eq!(debug, "IntoIter(['a', 'b', 'c'])"); } @@ -2336,7 +2336,7 @@ fn test_vec_dedup_panicking() { let ok = vec.iter().zip(expected.iter()).all(|(x, y)| x.index == y.index); if !ok { - panic!("expected: {:?}\ngot: {:?}\n", expected, vec); + panic!("expected: {expected:?}\ngot: {vec:?}\n"); } } diff --git a/library/alloc/tests/vec_deque.rs b/library/alloc/tests/vec_deque.rs index 18954f094c6..89cc7f905be 100644 --- a/library/alloc/tests/vec_deque.rs +++ b/library/alloc/tests/vec_deque.rs @@ -647,10 +647,10 @@ fn test_ord() { #[test] fn test_show() { let ringbuf: VecDeque<_> = (0..10).collect(); - assert_eq!(format!("{:?}", ringbuf), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"); + assert_eq!(format!("{ringbuf:?}"), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"); let ringbuf: VecDeque<_> = vec!["just", "one", "test", "more"].iter().cloned().collect(); - assert_eq!(format!("{:?}", ringbuf), "[\"just\", \"one\", \"test\", \"more\"]"); + assert_eq!(format!("{ringbuf:?}"), "[\"just\", \"one\", \"test\", \"more\"]"); } #[test] |
