parent
374ab25585
commit
42b10e51c1
|
@ -1876,6 +1876,7 @@ impl<T> VecDeque<T> {
|
||||||
/// assert_eq!(buf2, [2, 3]);
|
/// assert_eq!(buf2, [2, 3]);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[must_use = "use `.truncate()` if you don't need the other half"]
|
||||||
#[stable(feature = "split_off", since = "1.4.0")]
|
#[stable(feature = "split_off", since = "1.4.0")]
|
||||||
pub fn split_off(&mut self, at: usize) -> Self {
|
pub fn split_off(&mut self, at: usize) -> Self {
|
||||||
let len = self.len();
|
let len = self.len();
|
||||||
|
|
|
@ -1461,6 +1461,7 @@ impl String {
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "string_split_off", since = "1.16.0")]
|
#[stable(feature = "string_split_off", since = "1.16.0")]
|
||||||
|
#[must_use = "use `.truncate()` if you don't need the other half"]
|
||||||
pub fn split_off(&mut self, at: usize) -> String {
|
pub fn split_off(&mut self, at: usize) -> String {
|
||||||
assert!(self.is_char_boundary(at));
|
assert!(self.is_char_boundary(at));
|
||||||
let other = self.vec.split_off(at);
|
let other = self.vec.split_off(at);
|
||||||
|
|
|
@ -266,14 +266,14 @@ fn test_split_off_empty() {
|
||||||
fn test_split_off_past_end() {
|
fn test_split_off_past_end() {
|
||||||
let orig = "Hello, world!";
|
let orig = "Hello, world!";
|
||||||
let mut split = String::from(orig);
|
let mut split = String::from(orig);
|
||||||
split.split_off(orig.len() + 1);
|
let _ = split.split_off(orig.len() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn test_split_off_mid_char() {
|
fn test_split_off_mid_char() {
|
||||||
let mut orig = String::from("山");
|
let mut orig = String::from("山");
|
||||||
orig.split_off(1);
|
let _ = orig.split_off(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue