Move to to_owned rather than into_string.

into_string has been removed from Rust.
This commit is contained in:
Ms2ger 2015-01-20 14:45:36 +01:00
parent 2d5b0e0855
commit 01ed338746
67 changed files with 473 additions and 383 deletions

View file

@ -523,55 +523,56 @@ def_small_vector_clone_impl!(SmallVec32)
#[cfg(test)]
pub mod tests {
use smallvec::{SmallVec, SmallVec2, SmallVec16};
use std::borrow::ToOwned;
// We heap allocate all these strings so that double frees will show up under valgrind.
#[test]
pub fn test_inline() {
let mut v = SmallVec16::new();
v.push("hello".into_string());
v.push("there".into_string());
v.push("hello".to_owned());
v.push("there".to_owned());
assert_eq!(v.as_slice(), vec![
"hello".into_string(),
"there".into_string(),
"hello".to_owned(),
"there".to_owned(),
].as_slice());
}
#[test]
pub fn test_spill() {
let mut v = SmallVec2::new();
v.push("hello".into_string());
v.push("there".into_string());
v.push("burma".into_string());
v.push("shave".into_string());
v.push("hello".to_owned());
v.push("there".to_owned());
v.push("burma".to_owned());
v.push("shave".to_owned());
assert_eq!(v.as_slice(), vec![
"hello".into_string(),
"there".into_string(),
"burma".into_string(),
"shave".into_string(),
"hello".to_owned(),
"there".to_owned(),
"burma".to_owned(),
"shave".to_owned(),
].as_slice());
}
#[test]
pub fn test_double_spill() {
let mut v = SmallVec2::new();
v.push("hello".into_string());
v.push("there".into_string());
v.push("burma".into_string());
v.push("shave".into_string());
v.push("hello".into_string());
v.push("there".into_string());
v.push("burma".into_string());
v.push("shave".into_string());
v.push("hello".to_owned());
v.push("there".to_owned());
v.push("burma".to_owned());
v.push("shave".to_owned());
v.push("hello".to_owned());
v.push("there".to_owned());
v.push("burma".to_owned());
v.push("shave".to_owned());
assert_eq!(v.as_slice(), vec![
"hello".into_string(),
"there".into_string(),
"burma".into_string(),
"shave".into_string(),
"hello".into_string(),
"there".into_string(),
"burma".into_string(),
"shave".into_string(),
"hello".to_owned(),
"there".to_owned(),
"burma".to_owned(),
"shave".to_owned(),
"hello".to_owned(),
"there".to_owned(),
"burma".to_owned(),
"shave".to_owned(),
].as_slice());
}
}