@@ -1940,8 +1940,10 @@ impl String {
19401940
19411941    /// Converts this `String` into a <code>[Box]<[str]></code>. 
19421942     /// 
1943-      /// This will drop any excess capacity. 
1943+      /// Before doing the conversion, this method discards excess capacity like [`shrink_to_fit`]. 
1944+      /// Note that this call may reallocate and copy the bytes of the string. 
19441945     /// 
1946+      /// [`shrink_to_fit`]: String::shrink_to_fit 
19451947     /// [str]: prim@str "str" 
19461948     /// 
19471949     /// # Examples 
@@ -1967,10 +1969,10 @@ impl String {
19671969     /// this function is ideally used for data that lives for the remainder of the program's life, 
19681970     /// as dropping the returned reference will cause a memory leak. 
19691971     /// 
1970-      /// It does not reallocate or shrink the `String`, 
1971-      /// so the leaked allocation may include unused capacity that is not part  
1972-      /// of the returned slice. If you don't want that, call [`into_boxed_str`],  
1973-      /// and then [`Box::leak`] . 
1972+      /// It does not reallocate or shrink the `String`, so the leaked allocation may include unused  
1973+      /// capacity that is not part of the returned slice. If you want to discard excess capacity,  
1974+      /// call [`into_boxed_str`], and then [`Box::leak`] instead. However, keep in mind that  
1975+      /// trimming the capacity may result in a reallocation and copy . 
19741976     /// 
19751977     /// [`into_boxed_str`]: Self::into_boxed_str 
19761978     /// 
0 commit comments