Skip to content

Commit db2c70b

Browse files
authored
Rollup merge of #70359 - kornelski:mustsplit, r=Dylan-DPC
must_use on split_off A couple more for #70194
2 parents dc29016 + 42b10e5 commit db2c70b

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/liballoc/collections/vec_deque.rs

+1
Original file line numberDiff line numberDiff 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();

src/liballoc/string.rs

+1
Original file line numberDiff line numberDiff 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);

src/liballoc/tests/string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,14 @@ fn test_split_off_empty() {
266266
fn 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]
274274
fn 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]

0 commit comments

Comments
 (0)