File tree 3 files changed +4
-2
lines changed
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> {
1876
1876
/// assert_eq!(buf2, [2, 3]);
1877
1877
/// ```
1878
1878
#[ inline]
1879
+ #[ must_use = "use `.truncate()` if you don't need the other half" ]
1879
1880
#[ stable( feature = "split_off" , since = "1.4.0" ) ]
1880
1881
pub fn split_off ( & mut self , at : usize ) -> Self {
1881
1882
let len = self . len ( ) ;
Original file line number Diff line number Diff line change @@ -1461,6 +1461,7 @@ impl String {
1461
1461
/// ```
1462
1462
#[ inline]
1463
1463
#[ stable( feature = "string_split_off" , since = "1.16.0" ) ]
1464
+ #[ must_use = "use `.truncate()` if you don't need the other half" ]
1464
1465
pub fn split_off ( & mut self , at : usize ) -> String {
1465
1466
assert ! ( self . is_char_boundary( at) ) ;
1466
1467
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() {
266
266
fn test_split_off_past_end ( ) {
267
267
let orig = "Hello, world!" ;
268
268
let mut split = String :: from ( orig) ;
269
- split. split_off ( orig. len ( ) + 1 ) ;
269
+ let _ = split. split_off ( orig. len ( ) + 1 ) ;
270
270
}
271
271
272
272
#[ test]
273
273
#[ should_panic]
274
274
fn test_split_off_mid_char ( ) {
275
275
let mut orig = String :: from ( "山" ) ;
276
- orig. split_off ( 1 ) ;
276
+ let _ = orig. split_off ( 1 ) ;
277
277
}
278
278
279
279
#[ test]
You can’t perform that action at this time.
0 commit comments