File tree Expand file tree Collapse file tree 3 files changed +4
-2
lines changed Expand file tree Collapse file tree 3 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -1876,6 +1876,7 @@ impl<T> VecDeque<T> {
18761876 /// assert_eq!(buf2, [2, 3]);
18771877 /// ```
18781878 #[ inline]
1879+ #[ must_use = "use `.truncate()` if you don't need the other half" ]
18791880 #[ stable( feature = "split_off" , since = "1.4.0" ) ]
18801881 pub fn split_off ( & mut self , at : usize ) -> Self {
18811882 let len = self . len ( ) ;
Original file line number Diff line number Diff line change @@ -1461,6 +1461,7 @@ impl String {
14611461 /// ```
14621462 #[ inline]
14631463 #[ stable( feature = "string_split_off" , since = "1.16.0" ) ]
1464+ #[ must_use = "use `.truncate()` if you don't need the other half" ]
14641465 pub fn split_off ( & mut self , at : usize ) -> String {
14651466 assert ! ( self . is_char_boundary( at) ) ;
14661467 let other = self . vec . split_off ( at) ;
Original file line number Diff line number Diff line change @@ -266,14 +266,14 @@ fn test_split_off_empty() {
266266fn test_split_off_past_end ( ) {
267267 let orig = "Hello, world!" ;
268268 let mut split = String :: from ( orig) ;
269- split. split_off ( orig. len ( ) + 1 ) ;
269+ let _ = split. split_off ( orig. len ( ) + 1 ) ;
270270}
271271
272272#[ test]
273273#[ should_panic]
274274fn test_split_off_mid_char ( ) {
275275 let mut orig = String :: from ( "山" ) ;
276- orig. split_off ( 1 ) ;
276+ let _ = orig. split_off ( 1 ) ;
277277}
278278
279279#[ test]
You can’t perform that action at this time.
0 commit comments