fn test_into_vec() {
let xs = box [1u, 2, 3];
let ys = xs.into_vec();
- assert_eq!(ys.as_slice(), [1u, 2, 3]);
+ assert_eq!(ys.as_slice(), [1u, 2, 3].as_slice());
}
}
fn test_into_boxed_slice() {
let xs = vec![1u, 2, 3];
let ys = xs.into_boxed_slice();
- assert_eq!(ys.as_slice(), [1u, 2, 3]);
+ assert_eq!(ys.as_slice(), [1u, 2, 3].as_slice());
}
#[bench]
//! listener (socket server) implements the `Listener` and `Acceptor` traits.
use clone::Clone;
-use collections::MutableSeq;
use io::IoResult;
use iter::Iterator;
use slice::ImmutableSlice;
// The test runner calls ::std::os::args() but really wants realstd
#[cfg(test)] pub use realstd::os as os;
// The test runner requires std::slice::Vector, so re-export std::slice just for it.
- #[cfg(test)] pub use slice;
+ //
+ // It is also used in vec![]
+ pub use slice;
- pub use collections; // vec!() uses MutableSeq
+ pub use boxed; // used for vec![]
}
/// Create a `std::vec::Vec` containing the arguments.
#[macro_export]
-macro_rules! vec(
- ($($e:expr),*) => ({
- // leading _ to allow empty construction without a warning.
- let mut _temp = ::std::vec::Vec::new();
- $(_temp.push($e);)*
- _temp
+macro_rules! vec[
+ ($($x:expr),*) => ({
+ use std::slice::BoxedSlice;
+ let xs: ::std::boxed::Box<[_]> = box [$($x),*];
+ xs.into_vec()
});
- ($($e:expr),+,) => (vec!($($e),+))
-)
-
+ ($($x:expr,)*) => (vec![$($x),*])
+]
/// A macro to select an event from a number of receivers.
///