fn test_swap_remove_noncopyable() {
// Tests that we don't accidentally run destructors twice.
let mut v: Vec<Box<_>> = Vec::new();
- v.push(box 0);
- v.push(box 0);
- v.push(box 0);
+ v.push(Box::new(0));
+ v.push(Box::new(0));
+ v.push(Box::new(0));
let mut _e = v.swap_remove(0);
assert_eq!(v.len(), 2);
_e = v.swap_remove(1);
#[test]
fn test_truncate() {
- let mut v: Vec<Box<_>> = vec![box 6, box 5, box 4];
+ let mut v: Vec<Box<_>> = vec![Box::new(6), Box::new(5), Box::new(4)];
v.truncate(1);
let v = v;
assert_eq!(v.len(), 1);
#[test]
fn test_clear() {
- let mut v: Vec<Box<_>> = vec![box 6, box 5, box 4];
+ let mut v: Vec<Box<_>> = vec![Box::new(6), Box::new(5), Box::new(4)];
v.clear();
assert_eq!(v.len(), 0);
// If the unsafe block didn't drop things properly, we blow up here.
#[test]
fn test_to_vec() {
- let xs: Box<_> = box [1, 2, 3];
+ let xs: Box<_> = Box::new([1, 2, 3]);
let ys = xs.to_vec();
assert_eq!(ys, [1, 2, 3]);
}
#[test]
fn test_in_place_iterator_specialization() {
- let src: Box<[usize]> = box [1, 2, 3];
+ let src: Box<[usize]> = Box::new([1, 2, 3]);
let src_ptr = src.as_ptr();
let sink: Box<_> = src.into_vec().into_iter().map(std::convert::identity).collect();
let sink_ptr = sink.as_ptr();