diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index b082cffd66818..c56424159f483 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -399,7 +399,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) { procsrv::run("", config.adb_path.as_slice(), None, - [ + &[ "push".to_string(), exe_file.as_str().unwrap().to_string(), config.adb_test_dir.clone() @@ -411,7 +411,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) { procsrv::run("", config.adb_path.as_slice(), None, - [ + &[ "forward".to_string(), "tcp:5039".to_string(), "tcp:5039".to_string() @@ -432,7 +432,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) { config.adb_path .as_slice(), None, - [ + &[ "shell".to_string(), adb_arg.clone() ], @@ -746,7 +746,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path) cmd.arg(lldb_script_path) .arg(test_executable) .arg(debugger_script) - .env_set_all([("PYTHONPATH", config.lldb_python_dir.clone().unwrap().as_slice())]); + .env_set_all(&[("PYTHONPATH", config.lldb_python_dir.clone().unwrap().as_slice())]); let (status, out, err) = match cmd.spawn() { Ok(process) => { @@ -1142,11 +1142,11 @@ struct ProcRes { fn compile_test(config: &Config, props: &TestProps, testfile: &Path) -> ProcRes { - compile_test_(config, props, testfile, []) + compile_test_(config, props, testfile, &[]) } fn jit_test(config: &Config, props: &TestProps, testfile: &Path) -> ProcRes { - compile_test_(config, props, testfile, ["--jit".to_string()]) + compile_test_(config, props, testfile, &["--jit".to_string()]) } fn compile_test_(config: &Config, props: &TestProps, @@ -1507,7 +1507,7 @@ fn _arm_exec_compiled_test(config: &Config, let copy_result = procsrv::run("", config.adb_path.as_slice(), None, - [ + &[ "push".to_string(), args.prog.clone(), config.adb_test_dir.clone() @@ -1624,7 +1624,7 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) { let copy_result = procsrv::run("", config.adb_path.as_slice(), None, - [ + &[ "push".to_string(), file.as_str() .unwrap() diff --git a/src/doc/guide-testing.md b/src/doc/guide-testing.md index 4128ae9538b6a..a3bf810dde180 100644 --- a/src/doc/guide-testing.md +++ b/src/doc/guide-testing.md @@ -84,7 +84,7 @@ will be counted as a failure. For example: #[test] #[should_fail] fn test_out_of_bounds_failure() { - let v: &[int] = []; + let v: &[int] = &[]; v[0]; } ~~~ diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs index b7085c96aed15..df8f19e8a30b7 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -262,7 +262,7 @@ impl Bitv { /// ``` /// use std::collections::bitv; /// - /// let bv = bitv::from_bytes([0b01100000]); + /// let bv = bitv::from_bytes(&[0b01100000]); /// assert_eq!(bv.get(0), false); /// assert_eq!(bv.get(1), true); /// @@ -314,9 +314,9 @@ impl Bitv { /// let before = 0b01100000; /// let after = 0b11111111; /// - /// let mut bv = bitv::from_bytes([before]); + /// let mut bv = bitv::from_bytes(&[before]); /// bv.set_all(); - /// assert_eq!(bv, bitv::from_bytes([after])); + /// assert_eq!(bv, bitv::from_bytes(&[after])); /// ``` #[inline] pub fn set_all(&mut self) { @@ -333,9 +333,9 @@ impl Bitv { /// let before = 0b01100000; /// let after = 0b10011111; /// - /// let mut bv = bitv::from_bytes([before]); + /// let mut bv = bitv::from_bytes(&[before]); /// bv.negate(); - /// assert_eq!(bv, bitv::from_bytes([after])); + /// assert_eq!(bv, bitv::from_bytes(&[after])); /// ``` #[inline] pub fn negate(&mut self) { @@ -361,11 +361,11 @@ impl Bitv { /// let b = 0b01011010; /// let res = 0b01111110; /// - /// let mut a = bitv::from_bytes([a]); - /// let b = bitv::from_bytes([b]); + /// let mut a = bitv::from_bytes(&[a]); + /// let b = bitv::from_bytes(&[b]); /// /// assert!(a.union(&b)); - /// assert_eq!(a, bitv::from_bytes([res])); + /// assert_eq!(a, bitv::from_bytes(&[res])); /// ``` #[inline] pub fn union(&mut self, other: &Bitv) -> bool { @@ -391,11 +391,11 @@ impl Bitv { /// let b = 0b01011010; /// let res = 0b01000000; /// - /// let mut a = bitv::from_bytes([a]); - /// let b = bitv::from_bytes([b]); + /// let mut a = bitv::from_bytes(&[a]); + /// let b = bitv::from_bytes(&[b]); /// /// assert!(a.intersect(&b)); - /// assert_eq!(a, bitv::from_bytes([res])); + /// assert_eq!(a, bitv::from_bytes(&[res])); /// ``` #[inline] pub fn intersect(&mut self, other: &Bitv) -> bool { @@ -422,17 +422,17 @@ impl Bitv { /// let a_b = 0b00100100; // a - b /// let b_a = 0b00011010; // b - a /// - /// let mut bva = bitv::from_bytes([a]); - /// let bvb = bitv::from_bytes([b]); + /// let mut bva = bitv::from_bytes(&[a]); + /// let bvb = bitv::from_bytes(&[b]); /// /// assert!(bva.difference(&bvb)); - /// assert_eq!(bva, bitv::from_bytes([a_b])); + /// assert_eq!(bva, bitv::from_bytes(&[a_b])); /// - /// let bva = bitv::from_bytes([a]); - /// let mut bvb = bitv::from_bytes([b]); + /// let bva = bitv::from_bytes(&[a]); + /// let mut bvb = bitv::from_bytes(&[b]); /// /// assert!(bvb.difference(&bva)); - /// assert_eq!(bvb, bitv::from_bytes([b_a])); + /// assert_eq!(bvb, bitv::from_bytes(&[b_a])); /// ``` #[inline] pub fn difference(&mut self, other: &Bitv) -> bool { @@ -469,7 +469,7 @@ impl Bitv { /// ``` /// use std::collections::bitv; /// - /// let bv = bitv::from_bytes([0b01110100, 0b10010010]); + /// let bv = bitv::from_bytes(&[0b01110100, 0b10010010]); /// assert_eq!(bv.iter().filter(|x| *x).count(), 7); /// ``` #[inline] @@ -564,7 +564,7 @@ impl Bitv { /// ``` /// use std::collections::bitv; /// - /// let bv = bitv::from_bytes([0b10100000]); + /// let bv = bitv::from_bytes(&[0b10100000]); /// assert_eq!(bv.to_bools(), vec!(true, false, true, false, /// false, false, false, false)); /// ``` @@ -584,10 +584,10 @@ impl Bitv { /// ``` /// use std::collections::bitv; /// - /// let bv = bitv::from_bytes([0b10100000]); + /// let bv = bitv::from_bytes(&[0b10100000]); /// - /// assert!(bv.eq_vec([true, false, true, false, - /// false, false, false, false])); + /// assert!(bv.eq_vec(&[true, false, true, false, + /// false, false, false, false])); /// ``` pub fn eq_vec(&self, v: &[bool]) -> bool { assert_eq!(self.nbits, v.len()); @@ -609,9 +609,9 @@ impl Bitv { /// ``` /// use std::collections::bitv; /// - /// let mut bv = bitv::from_bytes([0b01001011]); + /// let mut bv = bitv::from_bytes(&[0b01001011]); /// bv.truncate(2); - /// assert!(bv.eq_vec([false, true])); + /// assert!(bv.eq_vec(&[false, true])); /// ``` pub fn truncate(&mut self, len: uint) { if len < self.len() { @@ -669,7 +669,7 @@ impl Bitv { /// ``` /// use std::collections::bitv; /// - /// let mut bv = bitv::from_bytes([0b01001011]); + /// let mut bv = bitv::from_bytes(&[0b01001011]); /// bv.grow(2, true); /// assert_eq!(bv.len(), 10); /// assert_eq!(bv.to_bytes(), vec!(0b01001011, 0b11000000)); @@ -721,7 +721,7 @@ impl Bitv { /// ``` /// use std::collections::bitv; /// - /// let mut bv = bitv::from_bytes([0b01001001]); + /// let mut bv = bitv::from_bytes(&[0b01001001]); /// assert_eq!(bv.pop(), true); /// assert_eq!(bv.pop(), false); /// assert_eq!(bv.len(), 6); @@ -747,7 +747,7 @@ impl Bitv { /// let mut bv = Bitv::new(); /// bv.push(true); /// bv.push(false); - /// assert!(bv.eq_vec([true, false])); + /// assert!(bv.eq_vec(&[true, false])); /// ``` pub fn push(&mut self, elem: bool) { let insert_pos = self.nbits; @@ -782,11 +782,11 @@ impl Bitv { /// ``` /// use std::collections::bitv; /// -/// let bv = bitv::from_bytes([0b10100000, 0b00010010]); -/// assert!(bv.eq_vec([true, false, true, false, -/// false, false, false, false, -/// false, false, false, true, -/// false, false, true, false])); +/// let bv = bitv::from_bytes(&[0b10100000, 0b00010010]); +/// assert!(bv.eq_vec(&[true, false, true, false, +/// false, false, false, false, +/// false, false, false, true, +/// false, false, true, false])); /// ``` pub fn from_bytes(bytes: &[u8]) -> Bitv { from_fn(bytes.len() * 8, |i| { @@ -805,7 +805,7 @@ pub fn from_bytes(bytes: &[u8]) -> Bitv { /// use std::collections::bitv::from_fn; /// /// let bv = from_fn(5, |i| { i % 2 == 0 }); -/// assert!(bv.eq_vec([true, false, true, false, true])); +/// assert!(bv.eq_vec(&[true, false, true, false, true])); /// ``` pub fn from_fn(len: uint, f: |index: uint| -> bool) -> Bitv { let mut bitv = Bitv::with_capacity(len, false); @@ -979,7 +979,7 @@ impl<'a> RandomAccessIterator for Bits<'a> { /// } /// /// // Can initialize from a `Bitv` -/// let other = BitvSet::from_bitv(bitv::from_bytes([0b11010000])); +/// let other = BitvSet::from_bitv(bitv::from_bytes(&[0b11010000])); /// /// s.union_with(&other); /// @@ -1079,7 +1079,7 @@ impl BitvSet { /// ``` /// use std::collections::{bitv, BitvSet}; /// - /// let bv = bitv::from_bytes([0b01100000]); + /// let bv = bitv::from_bytes(&[0b01100000]); /// let s = BitvSet::from_bitv(bv); /// /// // Print 1, 2 in arbitrary order @@ -1232,7 +1232,7 @@ impl BitvSet { /// use std::collections::BitvSet; /// use std::collections::bitv; /// - /// let s = BitvSet::from_bitv(bitv::from_bytes([0b01001010])); + /// let s = BitvSet::from_bitv(bitv::from_bytes(&[0b01001010])); /// /// // Print 1, 4, 6 in arbitrary order /// for x in s.iter() { @@ -1253,8 +1253,8 @@ impl BitvSet { /// use std::collections::BitvSet; /// use std::collections::bitv; /// - /// let a = BitvSet::from_bitv(bitv::from_bytes([0b01101000])); - /// let b = BitvSet::from_bitv(bitv::from_bytes([0b10100000])); + /// let a = BitvSet::from_bitv(bitv::from_bytes(&[0b01101000])); + /// let b = BitvSet::from_bitv(bitv::from_bytes(&[0b10100000])); /// /// // Print 0, 1, 2, 4 in arbitrary order /// for x in a.union(&b) { @@ -1281,8 +1281,8 @@ impl BitvSet { /// use std::collections::BitvSet; /// use std::collections::bitv; /// - /// let a = BitvSet::from_bitv(bitv::from_bytes([0b01101000])); - /// let b = BitvSet::from_bitv(bitv::from_bytes([0b10100000])); + /// let a = BitvSet::from_bitv(bitv::from_bytes(&[0b01101000])); + /// let b = BitvSet::from_bitv(bitv::from_bytes(&[0b10100000])); /// /// // Print 2 /// for x in a.intersection(&b) { @@ -1310,8 +1310,8 @@ impl BitvSet { /// use std::collections::BitvSet; /// use std::collections::bitv; /// - /// let a = BitvSet::from_bitv(bitv::from_bytes([0b01101000])); - /// let b = BitvSet::from_bitv(bitv::from_bytes([0b10100000])); + /// let a = BitvSet::from_bitv(bitv::from_bytes(&[0b01101000])); + /// let b = BitvSet::from_bitv(bitv::from_bytes(&[0b10100000])); /// /// // Print 1, 4 in arbitrary order /// for x in a.difference(&b) { @@ -1346,8 +1346,8 @@ impl BitvSet { /// use std::collections::BitvSet; /// use std::collections::bitv; /// - /// let a = BitvSet::from_bitv(bitv::from_bytes([0b01101000])); - /// let b = BitvSet::from_bitv(bitv::from_bytes([0b10100000])); + /// let a = BitvSet::from_bitv(bitv::from_bytes(&[0b01101000])); + /// let b = BitvSet::from_bitv(bitv::from_bytes(&[0b10100000])); /// /// // Print 0, 1, 4 in arbitrary order /// for x in a.symmetric_difference(&b) { @@ -1377,9 +1377,9 @@ impl BitvSet { /// let b = 0b10100000; /// let res = 0b11101000; /// - /// let mut a = BitvSet::from_bitv(bitv::from_bytes([a])); - /// let b = BitvSet::from_bitv(bitv::from_bytes([b])); - /// let res = BitvSet::from_bitv(bitv::from_bytes([res])); + /// let mut a = BitvSet::from_bitv(bitv::from_bytes(&[a])); + /// let b = BitvSet::from_bitv(bitv::from_bytes(&[b])); + /// let res = BitvSet::from_bitv(bitv::from_bytes(&[res])); /// /// a.union_with(&b); /// assert_eq!(a, res); @@ -1401,9 +1401,9 @@ impl BitvSet { /// let b = 0b10100000; /// let res = 0b00100000; /// - /// let mut a = BitvSet::from_bitv(bitv::from_bytes([a])); - /// let b = BitvSet::from_bitv(bitv::from_bytes([b])); - /// let res = BitvSet::from_bitv(bitv::from_bytes([res])); + /// let mut a = BitvSet::from_bitv(bitv::from_bytes(&[a])); + /// let b = BitvSet::from_bitv(bitv::from_bytes(&[b])); + /// let res = BitvSet::from_bitv(bitv::from_bytes(&[res])); /// /// a.intersect_with(&b); /// assert_eq!(a, res); @@ -1427,16 +1427,16 @@ impl BitvSet { /// let a_b = 0b01001000; // a - b /// let b_a = 0b10000000; // b - a /// - /// let mut bva = BitvSet::from_bitv(bitv::from_bytes([a])); - /// let bvb = BitvSet::from_bitv(bitv::from_bytes([b])); - /// let bva_b = BitvSet::from_bitv(bitv::from_bytes([a_b])); - /// let bvb_a = BitvSet::from_bitv(bitv::from_bytes([b_a])); + /// let mut bva = BitvSet::from_bitv(bitv::from_bytes(&[a])); + /// let bvb = BitvSet::from_bitv(bitv::from_bytes(&[b])); + /// let bva_b = BitvSet::from_bitv(bitv::from_bytes(&[a_b])); + /// let bvb_a = BitvSet::from_bitv(bitv::from_bytes(&[b_a])); /// /// bva.difference_with(&bvb); /// assert_eq!(bva, bva_b); /// - /// let bva = BitvSet::from_bitv(bitv::from_bytes([a])); - /// let mut bvb = BitvSet::from_bitv(bitv::from_bytes([b])); + /// let bva = BitvSet::from_bitv(bitv::from_bytes(&[a])); + /// let mut bvb = BitvSet::from_bitv(bitv::from_bytes(&[b])); /// /// bvb.difference_with(&bva); /// assert_eq!(bvb, bvb_a); @@ -1459,9 +1459,9 @@ impl BitvSet { /// let b = 0b10100000; /// let res = 0b11001000; /// - /// let mut a = BitvSet::from_bitv(bitv::from_bytes([a])); - /// let b = BitvSet::from_bitv(bitv::from_bytes([b])); - /// let res = BitvSet::from_bitv(bitv::from_bytes([res])); + /// let mut a = BitvSet::from_bitv(bitv::from_bytes(&[a])); + /// let b = BitvSet::from_bitv(bitv::from_bytes(&[b])); + /// let res = BitvSet::from_bitv(bitv::from_bytes(&[res])); /// /// a.symmetric_difference_with(&b); /// assert_eq!(a, res); @@ -1682,9 +1682,9 @@ mod tests { #[test] fn test_1_element() { let mut act = Bitv::with_capacity(1u, false); - assert!(act.eq_vec([false])); + assert!(act.eq_vec(&[false])); act = Bitv::with_capacity(1u, true); - assert!(act.eq_vec([true])); + assert!(act.eq_vec(&[true])); } #[test] @@ -1702,11 +1702,11 @@ mod tests { act = Bitv::with_capacity(10u, false); assert!((act.eq_vec( - [false, false, false, false, false, false, false, false, false, false]))); + &[false, false, false, false, false, false, false, false, false, false]))); // all 1 act = Bitv::with_capacity(10u, true); - assert!((act.eq_vec([true, true, true, true, true, true, true, true, true, true]))); + assert!((act.eq_vec(&[true, true, true, true, true, true, true, true, true, true]))); // mixed act = Bitv::with_capacity(10u, false); @@ -1715,7 +1715,7 @@ mod tests { act.set(2u, true); act.set(3u, true); act.set(4u, true); - assert!((act.eq_vec([true, true, true, true, true, false, false, false, false, false]))); + assert!((act.eq_vec(&[true, true, true, true, true, false, false, false, false, false]))); // mixed act = Bitv::with_capacity(10u, false); @@ -1724,7 +1724,7 @@ mod tests { act.set(7u, true); act.set(8u, true); act.set(9u, true); - assert!((act.eq_vec([false, false, false, false, false, true, true, true, true, true]))); + assert!((act.eq_vec(&[false, false, false, false, false, true, true, true, true, true]))); // mixed act = Bitv::with_capacity(10u, false); @@ -1732,7 +1732,7 @@ mod tests { act.set(3u, true); act.set(6u, true); act.set(9u, true); - assert!((act.eq_vec([true, false, false, true, false, false, true, false, false, true]))); + assert!((act.eq_vec(&[true, false, false, true, false, false, true, false, false, true]))); } #[test] @@ -1742,14 +1742,14 @@ mod tests { act = Bitv::with_capacity(31u, false); assert!(act.eq_vec( - [false, false, false, false, false, false, false, false, false, false, false, + &[false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false])); // all 1 act = Bitv::with_capacity(31u, true); assert!(act.eq_vec( - [true, true, true, true, true, true, true, true, true, true, true, true, true, + &[true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true])); // mixed @@ -1764,7 +1764,7 @@ mod tests { act.set(6u, true); act.set(7u, true); assert!(act.eq_vec( - [true, true, true, true, true, true, true, true, false, false, false, false, false, + &[true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false])); // mixed @@ -1779,7 +1779,7 @@ mod tests { act.set(22u, true); act.set(23u, true); assert!(act.eq_vec( - [false, false, false, false, false, false, false, false, false, false, false, + &[false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false])); // mixed @@ -1793,7 +1793,7 @@ mod tests { act.set(29u, true); act.set(30u, true); assert!(act.eq_vec( - [false, false, false, false, false, false, false, false, false, false, false, + &[false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true])); // mixed @@ -1803,7 +1803,7 @@ mod tests { act.set(17u, true); act.set(30u, true); assert!(act.eq_vec( - [false, false, false, true, false, false, false, false, false, false, false, false, + &[false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, true])); } @@ -1815,14 +1815,14 @@ mod tests { act = Bitv::with_capacity(32u, false); assert!(act.eq_vec( - [false, false, false, false, false, false, false, false, false, false, false, + &[false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false])); // all 1 act = Bitv::with_capacity(32u, true); assert!(act.eq_vec( - [true, true, true, true, true, true, true, true, true, true, true, true, true, + &[true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true])); // mixed @@ -1837,7 +1837,7 @@ mod tests { act.set(6u, true); act.set(7u, true); assert!(act.eq_vec( - [true, true, true, true, true, true, true, true, false, false, false, false, false, + &[true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false])); // mixed @@ -1852,7 +1852,7 @@ mod tests { act.set(22u, true); act.set(23u, true); assert!(act.eq_vec( - [false, false, false, false, false, false, false, false, false, false, false, + &[false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false])); // mixed @@ -1867,7 +1867,7 @@ mod tests { act.set(30u, true); act.set(31u, true); assert!(act.eq_vec( - [false, false, false, false, false, false, false, false, false, false, false, + &[false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true])); // mixed @@ -1878,7 +1878,7 @@ mod tests { act.set(30u, true); act.set(31u, true); assert!(act.eq_vec( - [false, false, false, true, false, false, false, false, false, false, false, false, + &[false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, true, true])); } @@ -1890,14 +1890,14 @@ mod tests { act = Bitv::with_capacity(33u, false); assert!(act.eq_vec( - [false, false, false, false, false, false, false, false, false, false, false, + &[false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false])); // all 1 act = Bitv::with_capacity(33u, true); assert!(act.eq_vec( - [true, true, true, true, true, true, true, true, true, true, true, true, true, + &[true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true])); // mixed @@ -1912,7 +1912,7 @@ mod tests { act.set(6u, true); act.set(7u, true); assert!(act.eq_vec( - [true, true, true, true, true, true, true, true, false, false, false, false, false, + &[true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false])); // mixed @@ -1927,7 +1927,7 @@ mod tests { act.set(22u, true); act.set(23u, true); assert!(act.eq_vec( - [false, false, false, false, false, false, false, false, false, false, false, + &[false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false])); // mixed @@ -1942,7 +1942,7 @@ mod tests { act.set(30u, true); act.set(31u, true); assert!(act.eq_vec( - [false, false, false, false, false, false, false, false, false, false, false, + &[false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, false])); // mixed @@ -1954,7 +1954,7 @@ mod tests { act.set(31u, true); act.set(32u, true); assert!(act.eq_vec( - [false, false, false, true, false, false, false, false, false, false, false, false, + &[false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true])); } @@ -2001,7 +2001,7 @@ mod tests { #[test] fn test_from_bytes() { - let bitv = from_bytes([0b10110110, 0b00000000, 0b11111111]); + let bitv = from_bytes(&[0b10110110, 0b00000000, 0b11111111]); let str = format!("{}{}{}", "10110110", "00000000", "11111111"); assert_eq!(bitv.to_string().as_slice(), str.as_slice()); } @@ -2039,7 +2039,7 @@ mod tests { #[test] fn test_to_bools() { let bools = vec!(false, false, true, false, false, true, true, false); - assert_eq!(from_bytes([0b00100110]).iter().collect::>(), bools); + assert_eq!(from_bytes(&[0b00100110]).iter().collect::>(), bools); } #[test] @@ -2277,10 +2277,10 @@ mod tests { #[test] fn test_bitv_set_is_disjoint() { - let a = BitvSet::from_bitv(from_bytes([0b10100010])); - let b = BitvSet::from_bitv(from_bytes([0b01000000])); + let a = BitvSet::from_bitv(from_bytes(&[0b10100010])); + let b = BitvSet::from_bitv(from_bytes(&[0b01000000])); let c = BitvSet::new(); - let d = BitvSet::from_bitv(from_bytes([0b00110000])); + let d = BitvSet::from_bitv(from_bytes(&[0b00110000])); assert!(!a.is_disjoint(&d)); assert!(!d.is_disjoint(&a)); @@ -2300,13 +2300,13 @@ mod tests { a.insert(0); let mut b = BitvSet::new(); b.insert(5); - let expected = BitvSet::from_bitv(from_bytes([0b10000100])); + let expected = BitvSet::from_bitv(from_bytes(&[0b10000100])); a.union_with(&b); assert_eq!(a, expected); // Standard - let mut a = BitvSet::from_bitv(from_bytes([0b10100010])); - let mut b = BitvSet::from_bitv(from_bytes([0b01100010])); + let mut a = BitvSet::from_bitv(from_bytes(&[0b10100010])); + let mut b = BitvSet::from_bitv(from_bytes(&[0b01100010])); let c = a.clone(); a.union_with(&b); b.union_with(&c); @@ -2317,8 +2317,8 @@ mod tests { #[test] fn test_bitv_set_intersect_with() { // Explicitly 0'ed bits - let mut a = BitvSet::from_bitv(from_bytes([0b10100010])); - let mut b = BitvSet::from_bitv(from_bytes([0b00000000])); + let mut a = BitvSet::from_bitv(from_bytes(&[0b10100010])); + let mut b = BitvSet::from_bitv(from_bytes(&[0b00000000])); let c = a.clone(); a.intersect_with(&b); b.intersect_with(&c); @@ -2326,7 +2326,7 @@ mod tests { assert!(b.is_empty()); // Uninitialized bits should behave like 0's - let mut a = BitvSet::from_bitv(from_bytes([0b10100010])); + let mut a = BitvSet::from_bitv(from_bytes(&[0b10100010])); let mut b = BitvSet::new(); let c = a.clone(); a.intersect_with(&b); @@ -2335,8 +2335,8 @@ mod tests { assert!(b.is_empty()); // Standard - let mut a = BitvSet::from_bitv(from_bytes([0b10100010])); - let mut b = BitvSet::from_bitv(from_bytes([0b01100010])); + let mut a = BitvSet::from_bitv(from_bytes(&[0b10100010])); + let mut b = BitvSet::from_bitv(from_bytes(&[0b01100010])); let c = a.clone(); a.intersect_with(&b); b.intersect_with(&c); @@ -2347,20 +2347,20 @@ mod tests { #[test] fn test_bitv_set_difference_with() { // Explicitly 0'ed bits - let mut a = BitvSet::from_bitv(from_bytes([0b00000000])); - let b = BitvSet::from_bitv(from_bytes([0b10100010])); + let mut a = BitvSet::from_bitv(from_bytes(&[0b00000000])); + let b = BitvSet::from_bitv(from_bytes(&[0b10100010])); a.difference_with(&b); assert!(a.is_empty()); // Uninitialized bits should behave like 0's let mut a = BitvSet::new(); - let b = BitvSet::from_bitv(from_bytes([0b11111111])); + let b = BitvSet::from_bitv(from_bytes(&[0b11111111])); a.difference_with(&b); assert!(a.is_empty()); // Standard - let mut a = BitvSet::from_bitv(from_bytes([0b10100010])); - let mut b = BitvSet::from_bitv(from_bytes([0b01100010])); + let mut a = BitvSet::from_bitv(from_bytes(&[0b10100010])); + let mut b = BitvSet::from_bitv(from_bytes(&[0b01100010])); let c = a.clone(); a.difference_with(&b); b.difference_with(&c); @@ -2377,19 +2377,19 @@ mod tests { let mut b = BitvSet::new(); b.insert(1); b.insert(5); - let expected = BitvSet::from_bitv(from_bytes([0b10000100])); + let expected = BitvSet::from_bitv(from_bytes(&[0b10000100])); a.symmetric_difference_with(&b); assert_eq!(a, expected); - let mut a = BitvSet::from_bitv(from_bytes([0b10100010])); + let mut a = BitvSet::from_bitv(from_bytes(&[0b10100010])); let b = BitvSet::new(); let c = a.clone(); a.symmetric_difference_with(&b); assert_eq!(a, c); // Standard - let mut a = BitvSet::from_bitv(from_bytes([0b11100010])); - let mut b = BitvSet::from_bitv(from_bytes([0b01101010])); + let mut a = BitvSet::from_bitv(from_bytes(&[0b11100010])); + let mut b = BitvSet::from_bitv(from_bytes(&[0b01101010])); let c = a.clone(); a.symmetric_difference_with(&b); b.symmetric_difference_with(&c); @@ -2399,8 +2399,8 @@ mod tests { #[test] fn test_bitv_set_eq() { - let a = BitvSet::from_bitv(from_bytes([0b10100010])); - let b = BitvSet::from_bitv(from_bytes([0b00000000])); + let a = BitvSet::from_bitv(from_bytes(&[0b10100010])); + let b = BitvSet::from_bitv(from_bytes(&[0b00000000])); let c = BitvSet::new(); assert!(a == a); @@ -2413,8 +2413,8 @@ mod tests { #[test] fn test_bitv_set_cmp() { - let a = BitvSet::from_bitv(from_bytes([0b10100010])); - let b = BitvSet::from_bitv(from_bytes([0b00000000])); + let a = BitvSet::from_bitv(from_bytes(&[0b10100010])); + let b = BitvSet::from_bitv(from_bytes(&[0b00000000])); let c = BitvSet::new(); assert_eq!(a.cmp(&b), Greater); @@ -2493,17 +2493,17 @@ mod tests { #[test] fn test_small_bitv_tests() { - let v = from_bytes([0]); + let v = from_bytes(&[0]); assert!(!v.all()); assert!(!v.any()); assert!(v.none()); - let v = from_bytes([0b00010100]); + let v = from_bytes(&[0b00010100]); assert!(!v.all()); assert!(v.any()); assert!(!v.none()); - let v = from_bytes([0xFF]); + let v = from_bytes(&[0xFF]); assert!(v.all()); assert!(v.any()); assert!(!v.none()); @@ -2511,7 +2511,7 @@ mod tests { #[test] fn test_big_bitv_tests() { - let v = from_bytes([ // 88 bits + let v = from_bytes(&[ // 88 bits 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); @@ -2519,7 +2519,7 @@ mod tests { assert!(!v.any()); assert!(v.none()); - let v = from_bytes([ // 88 bits + let v = from_bytes(&[ // 88 bits 0, 0, 0b00010100, 0, 0, 0, 0, 0b00110100, 0, 0, 0]); @@ -2527,7 +2527,7 @@ mod tests { assert!(v.any()); assert!(!v.none()); - let v = from_bytes([ // 88 bits + let v = from_bytes(&[ // 88 bits 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]); @@ -2606,25 +2606,25 @@ mod tests { #[test] fn test_bitv_grow() { - let mut bitv = from_bytes([0b10110110, 0b00000000, 0b10101010]); + let mut bitv = from_bytes(&[0b10110110, 0b00000000, 0b10101010]); bitv.grow(32, true); - assert_eq!(bitv, from_bytes([0b10110110, 0b00000000, 0b10101010, - 0xFF, 0xFF, 0xFF, 0xFF])); + assert_eq!(bitv, from_bytes(&[0b10110110, 0b00000000, 0b10101010, + 0xFF, 0xFF, 0xFF, 0xFF])); bitv.grow(64, false); - assert_eq!(bitv, from_bytes([0b10110110, 0b00000000, 0b10101010, - 0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0])); + assert_eq!(bitv, from_bytes(&[0b10110110, 0b00000000, 0b10101010, + 0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0])); bitv.grow(16, true); - assert_eq!(bitv, from_bytes([0b10110110, 0b00000000, 0b10101010, - 0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF])); + assert_eq!(bitv, from_bytes(&[0b10110110, 0b00000000, 0b10101010, + 0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF])); } #[test] fn test_bitv_extend() { - let mut bitv = from_bytes([0b10110110, 0b00000000, 0b11111111]); - let ext = from_bytes([0b01001001, 0b10010010, 0b10111101]); + let mut bitv = from_bytes(&[0b10110110, 0b00000000, 0b11111111]); + let ext = from_bytes(&[0b01001001, 0b10010010, 0b10111101]); bitv.extend(ext.iter()); - assert_eq!(bitv, from_bytes([0b10110110, 0b00000000, 0b11111111, - 0b01001001, 0b10010010, 0b10111101])); + assert_eq!(bitv, from_bytes(&[0b10110110, 0b00000000, 0b11111111, + 0b01001001, 0b10010010, 0b10111101])); } #[test] diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs index 27752207b9797..88833c4584c2a 100644 --- a/src/libcollections/btree/set.rs +++ b/src/libcollections/btree/set.rs @@ -448,14 +448,14 @@ mod test { check(a, b, expected, |x, y, f| x.intersection(y).all(f)) } - check_intersection([], [], []); - check_intersection([1, 2, 3], [], []); - check_intersection([], [1, 2, 3], []); - check_intersection([2], [1, 2, 3], [2]); - check_intersection([1, 2, 3], [2], [2]); - check_intersection([11, 1, 3, 77, 103, 5, -5], - [2, 11, 77, -9, -42, 5, 3], - [3, 5, 11, 77]); + check_intersection(&[], &[], &[]); + check_intersection(&[1, 2, 3], &[], &[]); + check_intersection(&[], &[1, 2, 3], &[]); + check_intersection(&[2], &[1, 2, 3], &[2]); + check_intersection(&[1, 2, 3], &[2], &[2]); + check_intersection(&[11, 1, 3, 77, 103, 5, -5], + &[2, 11, 77, -9, -42, 5, 3], + &[3, 5, 11, 77]); } #[test] @@ -464,15 +464,15 @@ mod test { check(a, b, expected, |x, y, f| x.difference(y).all(f)) } - check_difference([], [], []); - check_difference([1, 12], [], [1, 12]); - check_difference([], [1, 2, 3, 9], []); - check_difference([1, 3, 5, 9, 11], - [3, 9], - [1, 5, 11]); - check_difference([-5, 11, 22, 33, 40, 42], - [-12, -5, 14, 23, 34, 38, 39, 50], - [11, 22, 33, 40, 42]); + check_difference(&[], &[], &[]); + check_difference(&[1, 12], &[], &[1, 12]); + check_difference(&[], &[1, 2, 3, 9], &[]); + check_difference(&[1, 3, 5, 9, 11], + &[3, 9], + &[1, 5, 11]); + check_difference(&[-5, 11, 22, 33, 40, 42], + &[-12, -5, 14, 23, 34, 38, 39, 50], + &[11, 22, 33, 40, 42]); } #[test] @@ -482,12 +482,12 @@ mod test { check(a, b, expected, |x, y, f| x.symmetric_difference(y).all(f)) } - check_symmetric_difference([], [], []); - check_symmetric_difference([1, 2, 3], [2], [1, 3]); - check_symmetric_difference([2], [1, 2, 3], [1, 3]); - check_symmetric_difference([1, 3, 5, 9, 11], - [-2, 3, 9, 14, 22], - [-2, 1, 5, 11, 14, 22]); + check_symmetric_difference(&[], &[], &[]); + check_symmetric_difference(&[1, 2, 3], &[2], &[1, 3]); + check_symmetric_difference(&[2], &[1, 2, 3], &[1, 3]); + check_symmetric_difference(&[1, 3, 5, 9, 11], + &[-2, 3, 9, 14, 22], + &[-2, 1, 5, 11, 14, 22]); } #[test] @@ -497,12 +497,12 @@ mod test { check(a, b, expected, |x, y, f| x.union(y).all(f)) } - check_union([], [], []); - check_union([1, 2, 3], [2], [1, 2, 3]); - check_union([2], [1, 2, 3], [1, 2, 3]); - check_union([1, 3, 5, 9, 11, 16, 19, 24], - [-2, 1, 5, 9, 13, 19], - [-2, 1, 3, 5, 9, 11, 13, 16, 19, 24]); + check_union(&[], &[], &[]); + check_union(&[1, 2, 3], &[2], &[1, 2, 3]); + check_union(&[2], &[1, 2, 3], &[1, 2, 3]); + check_union(&[1, 3, 5, 9, 11, 16, 19, 24], + &[-2, 1, 5, 9, 13, 19], + &[-2, 1, 3, 5, 9, 11, 13, 16, 19, 24]); } #[test] diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index a1e286d124574..32408f0705f20 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -1061,8 +1061,8 @@ mod tests { #[test] fn test_merge() { - let mut m = list_from([0i, 1, 3, 5, 6, 7, 2]); - let n = list_from([-1i, 0, 0, 7, 7, 9]); + let mut m = list_from(&[0i, 1, 3, 5, 6, 7, 2]); + let n = list_from(&[-1i, 0, 0, 7, 7, 9]); let len = m.len() + n.len(); m.merge(n, |a, b| a <= b); assert_eq!(m.len(), len); @@ -1102,7 +1102,7 @@ mod tests { #[test] fn test_send() { - let n = list_from([1i,2,3]); + let n = list_from(&[1i,2,3]); spawn(proc() { check_links(&n); let a: &[_] = &[&1,&2,&3]; @@ -1112,16 +1112,16 @@ mod tests { #[test] fn test_eq() { - let mut n: DList = list_from([]); - let mut m = list_from([]); + let mut n: DList = list_from(&[]); + let mut m = list_from(&[]); assert!(n == m); n.push_front(1); assert!(n != m); m.push(1); assert!(n == m); - let n = list_from([2i,3,4]); - let m = list_from([1i,2,3]); + let n = list_from(&[2i,3,4]); + let m = list_from(&[1i,2,3]); assert!(n != m); } @@ -1145,8 +1145,8 @@ mod tests { #[test] fn test_ord() { - let n: DList = list_from([]); - let m = list_from([1i,2,3]); + let n: DList = list_from(&[]); + let m = list_from(&[1i,2,3]); assert!(n < m); assert!(m > n); assert!(n <= n); @@ -1156,29 +1156,29 @@ mod tests { #[test] fn test_ord_nan() { let nan = 0.0f64/0.0; - let n = list_from([nan]); - let m = list_from([nan]); + let n = list_from(&[nan]); + let m = list_from(&[nan]); assert!(!(n < m)); assert!(!(n > m)); assert!(!(n <= m)); assert!(!(n >= m)); - let n = list_from([nan]); - let one = list_from([1.0f64]); + let n = list_from(&[nan]); + let one = list_from(&[1.0f64]); assert!(!(n < one)); assert!(!(n > one)); assert!(!(n <= one)); assert!(!(n >= one)); - let u = list_from([1.0f64,2.0,nan]); - let v = list_from([1.0f64,2.0,3.0]); + let u = list_from(&[1.0f64,2.0,nan]); + let v = list_from(&[1.0f64,2.0,3.0]); assert!(!(u < v)); assert!(!(u > v)); assert!(!(u <= v)); assert!(!(u >= v)); - let s = list_from([1.0f64,2.0,4.0,2.0]); - let t = list_from([1.0f64,2.0,3.0,2.0]); + let s = list_from(&[1.0f64,2.0,4.0,2.0]); + let t = list_from(&[1.0f64,2.0,3.0,2.0]); assert!(!(s < t)); assert!(s > one); assert!(!(s <= one)); diff --git a/src/libcollections/hash/mod.rs b/src/libcollections/hash/mod.rs index 6c1a4019bd83f..6c71aa1e84b53 100644 --- a/src/libcollections/hash/mod.rs +++ b/src/libcollections/hash/mod.rs @@ -150,7 +150,7 @@ macro_rules! impl_hash_tuple( impl Hash for () { #[inline] fn hash(&self, state: &mut S) { - state.write([]); + state.write(&[]); } } ); diff --git a/src/libcollections/hash/sip.rs b/src/libcollections/hash/sip.rs index dd105c44ad336..667147072012f 100644 --- a/src/libcollections/hash/sip.rs +++ b/src/libcollections/hash/sip.rs @@ -414,7 +414,7 @@ mod tests { assert_eq!(f, v); buf.push(t as u8); - state_inc.write([t as u8]); + state_inc.write(&[t as u8]); t += 1; } diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index eb4ff345b5133..49594d9e0108f 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -18,7 +18,7 @@ //! let vec = vec!(1i, 2, 3); //! let int_slice = vec.as_slice(); //! // coercing an array to a slice -//! let str_slice: &[&str] = ["one", "two", "three"]; +//! let str_slice: &[&str] = &["one", "two", "three"]; //! ``` //! //! Slices are either mutable or shared. The shared slice type is `&[T]`, @@ -26,7 +26,7 @@ //! block of memory that a mutable slice points to: //! //! ```rust -//! let x: &mut[int] = [1i, 2, 3]; +//! let x: &mut[int] = &mut [1i, 2, 3]; //! x[1] = 7; //! assert_eq!(x[0], 1); //! assert_eq!(x[1], 7); @@ -576,11 +576,11 @@ pub trait MutableSliceAllocating for Sized? { /// ```rust /// let mut v = [5i, 4, 1, 3, 2]; /// v.sort_by(|a, b| a.cmp(b)); - /// assert!(v == [1, 2, 3, 4, 5]); + /// assert!(v == &[1, 2, 3, 4, 5]); /// /// // reverse sorting /// v.sort_by(|a, b| b.cmp(a)); - /// assert!(v == [5, 4, 3, 2, 1]); + /// assert!(v == &[5, 4, 3, 2, 1]); /// ``` fn sort_by(&mut self, compare: |&T, &T| -> Ordering); @@ -603,7 +603,7 @@ pub trait MutableSliceAllocating for Sized? { /// let b = vec![6i, 7, 8]; /// let num_moved = a.move_from(b, 0, 3); /// assert_eq!(num_moved, 3); - /// assert!(a == [6i, 7, 8, 4, 5]); + /// assert!(a == &[6i, 7, 8, 4, 5]); /// ``` fn move_from(&mut self, src: Vec, start: uint, end: uint) -> uint; } @@ -636,7 +636,7 @@ pub trait MutableOrdSlice for Sized? { /// let mut v = [-5i, 4, 1, -3, 2]; /// /// v.sort(); - /// assert!(v == [-5i, -3, 1, 2, 4]); + /// assert!(v == &[-5i, -3, 1, 2, 4]); /// ``` fn sort(&mut self); @@ -1173,12 +1173,12 @@ mod tests { for (i, (a, b)) in ElementSwaps::new(v.len()).enumerate() { v.swap(a, b); match i { - 0 => assert!(v == [1, 3, 2]), - 1 => assert!(v == [3, 1, 2]), - 2 => assert!(v == [3, 2, 1]), - 3 => assert!(v == [2, 3, 1]), - 4 => assert!(v == [2, 1, 3]), - 5 => assert!(v == [1, 2, 3]), + 0 => assert!(v == &[1, 3, 2]), + 1 => assert!(v == &[3, 1, 2]), + 2 => assert!(v == &[3, 2, 1]), + 3 => assert!(v == &[2, 3, 1]), + 4 => assert!(v == &[2, 1, 3]), + 5 => assert!(v == &[1, 2, 3]), _ => panic!(), } } @@ -1395,7 +1395,7 @@ mod tests { let mut v = [0xDEADBEEFu]; v.sort(); - assert!(v == [0xDEADBEEF]); + assert!(v == &[0xDEADBEEF]); } #[test] @@ -1689,7 +1689,7 @@ mod tests { for x in xs.iter_mut() { *x += 1; } - assert!(xs == [2, 3, 4, 5, 6]) + assert!(xs == &[2, 3, 4, 5, 6]) } #[test] @@ -1711,7 +1711,7 @@ mod tests { for (i,x) in xs.iter_mut().rev().enumerate() { *x += i; } - assert!(xs == [5, 5, 5, 5, 5]) + assert!(xs == &[5, 5, 5, 5, 5]) } #[test] @@ -1885,26 +1885,26 @@ mod tests { let mut a = [1i,2,3,4,5]; let b = vec![6i,7,8]; assert_eq!(a.move_from(b, 0, 3), 3); - assert!(a == [6i,7,8,4,5]); + assert!(a == &mut [6i,7,8,4,5]); let mut a = [7i,2,8,1]; let b = vec![3i,1,4,1,5,9]; assert_eq!(a.move_from(b, 0, 6), 4); - assert!(a == [3i,1,4,1]); + assert!(a == &mut [3i,1,4,1]); let mut a = [1i,2,3,4]; let b = vec![5i,6,7,8,9,0]; assert_eq!(a.move_from(b, 2, 3), 1); - assert!(a == [7i,2,3,4]); + assert!(a == &mut [7i,2,3,4]); let mut a = [1i,2,3,4,5]; let b = vec![5i,6,7,8,9,0]; assert_eq!(a[mut 2..4].move_from(b,1,6), 2); - assert!(a == [1i,2,6,7,5]); + assert!(a == &mut [1i,2,6,7,5]); } #[test] fn test_reverse_part() { let mut values = [1i,2,3,4,5]; values[mut 1..4].reverse(); - assert!(values == [1,4,3,2,5]); + assert!(values == &mut [1,4,3,2,5]); } #[test] @@ -1949,11 +1949,11 @@ mod tests { #[test] fn test_bytes_set_memory() { use slice::bytes::MutableByteVector; - let mut values = [1u8,2,3,4,5]; + let values: &mut [_] = &mut [1u8,2,3,4,5]; values[mut 0..5].set_memory(0xAB); - assert!(values == [0xAB, 0xAB, 0xAB, 0xAB, 0xAB]); + assert!(values == &mut [0xAB, 0xAB, 0xAB, 0xAB, 0xAB]); values[mut 2..4].set_memory(0xFF); - assert!(values == [0xAB, 0xAB, 0xFF, 0xFF, 0xAB]); + assert!(values == &mut [0xAB, 0xAB, 0xFF, 0xFF, 0xAB]); } #[test] @@ -1995,7 +1995,7 @@ mod tests { } } - assert!(values == [2, 3, 5, 6, 7]); + assert!(values == &[2, 3, 5, 6, 7]); } #[deriving(Clone, PartialEq)] @@ -2060,7 +2060,7 @@ mod tests { assert!(!b"foo".starts_with(b"foobar")); assert!(!b"bar".starts_with(b"foobar")); assert!(b"foobar".starts_with(b"foobar")); - let empty: &[u8] = []; + let empty: &[u8] = &[]; assert!(empty.starts_with(empty)); assert!(!empty.starts_with(b"foo")); assert!(b"foobar".starts_with(empty)); @@ -2074,7 +2074,7 @@ mod tests { assert!(!b"foo".ends_with(b"foobar")); assert!(!b"bar".ends_with(b"foobar")); assert!(b"foobar".ends_with(b"foobar")); - let empty: &[u8] = []; + let empty: &[u8] = &[]; assert!(empty.ends_with(empty)); assert!(!empty.ends_with(b"foo")); assert!(b"foobar".ends_with(empty)); @@ -2087,13 +2087,13 @@ mod tests { for slice in xs.split_mut(|x| *x == 0) { slice.reverse(); } - assert!(xs == [0,1,0,3,2,0,0,5,4,0]); + assert!(xs == &[0,1,0,3,2,0,0,5,4,0]); let mut xs = [0i,1,0,2,3,0,0,4,5,0,6,7]; for slice in xs.split_mut(|x| *x == 0).take(5) { slice.reverse(); } - assert!(xs == [0,1,0,3,2,0,0,5,4,0,6,7]); + assert!(xs == &[0,1,0,3,2,0,0,5,4,0,6,7]); } #[test] @@ -2102,7 +2102,7 @@ mod tests { for slice in xs.split_mut(|x| *x == 0).rev().take(4) { slice.reverse(); } - assert!(xs == [1,2,0,4,3,0,0,6,5,0]); + assert!(xs == &[1,2,0,4,3,0,0,6,5,0]); } #[test] @@ -2124,7 +2124,7 @@ mod tests { } } let result = [0u8, 0, 0, 1, 1, 1, 2]; - assert!(v == result); + assert!(v == &result); } #[test] @@ -2136,7 +2136,7 @@ mod tests { } } let result = [2u8, 2, 2, 1, 1, 1, 0]; - assert!(v == result); + assert!(v == &result); } #[test] @@ -2152,7 +2152,7 @@ mod tests { let h = x.last_mut(); assert_eq!(*h.unwrap(), 5); - let y: &mut [int] = []; + let y: &mut [int] = &mut []; assert!(y.last_mut().is_none()); } @@ -2318,7 +2318,7 @@ mod bench { v.set_len(1024); } for i in range(0u, 1024) { - *v.get_mut(i) = 0; + v[i] = 0; } }); } diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index ff756a8eef3c3..6e88e02415c77 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -920,13 +920,13 @@ mod tests { fn t(v: &[String], s: &str) { assert_eq!(v.concat().as_slice(), s); } - t([String::from_str("you"), String::from_str("know"), - String::from_str("I'm"), - String::from_str("no"), String::from_str("good")], + t(&[String::from_str("you"), String::from_str("know"), + String::from_str("I'm"), + String::from_str("no"), String::from_str("good")], "youknowI'mnogood"); - let v: &[String] = []; + let v: &[String] = &[]; t(v, ""); - t([String::from_str("hi")], "hi"); + t(&[String::from_str("hi")], "hi"); } #[test] @@ -934,13 +934,13 @@ mod tests { fn t(v: &[String], sep: &str, s: &str) { assert_eq!(v.connect(sep).as_slice(), s); } - t([String::from_str("you"), String::from_str("know"), - String::from_str("I'm"), - String::from_str("no"), String::from_str("good")], + t(&[String::from_str("you"), String::from_str("know"), + String::from_str("I'm"), + String::from_str("no"), String::from_str("good")], " ", "you know I'm no good"); - let v: &[String] = []; + let v: &[String] = &[]; t(v, " ", ""); - t([String::from_str("hi")], " ", "hi"); + t(&[String::from_str("hi")], " ", "hi"); } #[test] @@ -948,10 +948,10 @@ mod tests { fn t(v: &[&str], s: &str) { assert_eq!(v.concat().as_slice(), s); } - t(["you", "know", "I'm", "no", "good"], "youknowI'mnogood"); - let v: &[&str] = []; + t(&["you", "know", "I'm", "no", "good"], "youknowI'mnogood"); + let v: &[&str] = &[]; t(v, ""); - t(["hi"], "hi"); + t(&["hi"], "hi"); } #[test] @@ -959,10 +959,10 @@ mod tests { fn t(v: &[&str], sep: &str, s: &str) { assert_eq!(v.connect(sep).as_slice(), s); } - t(["you", "know", "I'm", "no", "good"], + t(&["you", "know", "I'm", "no", "good"], " ", "you know I'm no good"); - t([], " ", ""); - t(["hi"], " ", "hi"); + t(&[], " ", ""); + t(&["hi"], " ", "hi"); } #[test] @@ -1263,26 +1263,26 @@ mod tests { #[test] fn test_is_utf8() { // deny overlong encodings - assert!(!is_utf8([0xc0, 0x80])); - assert!(!is_utf8([0xc0, 0xae])); - assert!(!is_utf8([0xe0, 0x80, 0x80])); - assert!(!is_utf8([0xe0, 0x80, 0xaf])); - assert!(!is_utf8([0xe0, 0x81, 0x81])); - assert!(!is_utf8([0xf0, 0x82, 0x82, 0xac])); - assert!(!is_utf8([0xf4, 0x90, 0x80, 0x80])); + assert!(!is_utf8(&[0xc0, 0x80])); + assert!(!is_utf8(&[0xc0, 0xae])); + assert!(!is_utf8(&[0xe0, 0x80, 0x80])); + assert!(!is_utf8(&[0xe0, 0x80, 0xaf])); + assert!(!is_utf8(&[0xe0, 0x81, 0x81])); + assert!(!is_utf8(&[0xf0, 0x82, 0x82, 0xac])); + assert!(!is_utf8(&[0xf4, 0x90, 0x80, 0x80])); // deny surrogates - assert!(!is_utf8([0xED, 0xA0, 0x80])); - assert!(!is_utf8([0xED, 0xBF, 0xBF])); + assert!(!is_utf8(&[0xED, 0xA0, 0x80])); + assert!(!is_utf8(&[0xED, 0xBF, 0xBF])); - assert!(is_utf8([0xC2, 0x80])); - assert!(is_utf8([0xDF, 0xBF])); - assert!(is_utf8([0xE0, 0xA0, 0x80])); - assert!(is_utf8([0xED, 0x9F, 0xBF])); - assert!(is_utf8([0xEE, 0x80, 0x80])); - assert!(is_utf8([0xEF, 0xBF, 0xBF])); - assert!(is_utf8([0xF0, 0x90, 0x80, 0x80])); - assert!(is_utf8([0xF4, 0x8F, 0xBF, 0xBF])); + assert!(is_utf8(&[0xC2, 0x80])); + assert!(is_utf8(&[0xDF, 0xBF])); + assert!(is_utf8(&[0xE0, 0xA0, 0x80])); + assert!(is_utf8(&[0xED, 0x9F, 0xBF])); + assert!(is_utf8(&[0xEE, 0x80, 0x80])); + assert!(is_utf8(&[0xEF, 0xBF, 0xBF])); + assert!(is_utf8(&[0xF0, 0x90, 0x80, 0x80])); + assert!(is_utf8(&[0xF4, 0x8F, 0xBF, 0xBF])); } #[test] @@ -1290,58 +1290,58 @@ mod tests { macro_rules! pos ( ($($e:expr),*) => { { $(assert!(is_utf16($e));)* } }); // non-surrogates - pos!([0x0000], - [0x0001, 0x0002], - [0xD7FF], - [0xE000]); + pos!(&[0x0000], + &[0x0001, 0x0002], + &[0xD7FF], + &[0xE000]); // surrogate pairs (randomly generated with Python 3's // .encode('utf-16be')) - pos!([0xdb54, 0xdf16, 0xd880, 0xdee0, 0xdb6a, 0xdd45], - [0xd91f, 0xdeb1, 0xdb31, 0xdd84, 0xd8e2, 0xde14], - [0xdb9f, 0xdc26, 0xdb6f, 0xde58, 0xd850, 0xdfae]); + pos!(&[0xdb54, 0xdf16, 0xd880, 0xdee0, 0xdb6a, 0xdd45], + &[0xd91f, 0xdeb1, 0xdb31, 0xdd84, 0xd8e2, 0xde14], + &[0xdb9f, 0xdc26, 0xdb6f, 0xde58, 0xd850, 0xdfae]); // mixtures (also random) - pos!([0xd921, 0xdcc2, 0x002d, 0x004d, 0xdb32, 0xdf65], - [0xdb45, 0xdd2d, 0x006a, 0xdacd, 0xddfe, 0x0006], - [0x0067, 0xd8ff, 0xddb7, 0x000f, 0xd900, 0xdc80]); + pos!(&[0xd921, 0xdcc2, 0x002d, 0x004d, 0xdb32, 0xdf65], + &[0xdb45, 0xdd2d, 0x006a, 0xdacd, 0xddfe, 0x0006], + &[0x0067, 0xd8ff, 0xddb7, 0x000f, 0xd900, 0xdc80]); // negative tests macro_rules! neg ( ($($e:expr),*) => { { $(assert!(!is_utf16($e));)* } }); neg!( // surrogate + regular unit - [0xdb45, 0x0000], + &[0xdb45, 0x0000], // surrogate + lead surrogate - [0xd900, 0xd900], + &[0xd900, 0xd900], // unterminated surrogate - [0xd8ff], + &[0xd8ff], // trail surrogate without a lead - [0xddb7]); + &[0xddb7]); // random byte sequences that Python 3's .decode('utf-16be') // failed on - neg!([0x5b3d, 0x0141, 0xde9e, 0x8fdc, 0xc6e7], - [0xdf5a, 0x82a5, 0x62b9, 0xb447, 0x92f3], - [0xda4e, 0x42bc, 0x4462, 0xee98, 0xc2ca], - [0xbe00, 0xb04a, 0x6ecb, 0xdd89, 0xe278], - [0x0465, 0xab56, 0xdbb6, 0xa893, 0x665e], - [0x6b7f, 0x0a19, 0x40f4, 0xa657, 0xdcc5], - [0x9b50, 0xda5e, 0x24ec, 0x03ad, 0x6dee], - [0x8d17, 0xcaa7, 0xf4ae, 0xdf6e, 0xbed7], - [0xdaee, 0x2584, 0x7d30, 0xa626, 0x121a], - [0xd956, 0x4b43, 0x7570, 0xccd6, 0x4f4a], - [0x9dcf, 0x1b49, 0x4ba5, 0xfce9, 0xdffe], - [0x6572, 0xce53, 0xb05a, 0xf6af, 0xdacf], - [0x1b90, 0x728c, 0x9906, 0xdb68, 0xf46e], - [0x1606, 0xbeca, 0xbe76, 0x860f, 0xdfa5], - [0x8b4f, 0xde7a, 0xd220, 0x9fac, 0x2b6f], - [0xb8fe, 0xebbe, 0xda32, 0x1a5f, 0x8b8b], - [0x934b, 0x8956, 0xc434, 0x1881, 0xddf7], - [0x5a95, 0x13fc, 0xf116, 0xd89b, 0x93f9], - [0xd640, 0x71f1, 0xdd7d, 0x77eb, 0x1cd8], - [0x348b, 0xaef0, 0xdb2c, 0xebf1, 0x1282], - [0x50d7, 0xd824, 0x5010, 0xb369, 0x22ea]); + neg!(&[0x5b3d, 0x0141, 0xde9e, 0x8fdc, 0xc6e7], + &[0xdf5a, 0x82a5, 0x62b9, 0xb447, 0x92f3], + &[0xda4e, 0x42bc, 0x4462, 0xee98, 0xc2ca], + &[0xbe00, 0xb04a, 0x6ecb, 0xdd89, 0xe278], + &[0x0465, 0xab56, 0xdbb6, 0xa893, 0x665e], + &[0x6b7f, 0x0a19, 0x40f4, 0xa657, 0xdcc5], + &[0x9b50, 0xda5e, 0x24ec, 0x03ad, 0x6dee], + &[0x8d17, 0xcaa7, 0xf4ae, 0xdf6e, 0xbed7], + &[0xdaee, 0x2584, 0x7d30, 0xa626, 0x121a], + &[0xd956, 0x4b43, 0x7570, 0xccd6, 0x4f4a], + &[0x9dcf, 0x1b49, 0x4ba5, 0xfce9, 0xdffe], + &[0x6572, 0xce53, 0xb05a, 0xf6af, 0xdacf], + &[0x1b90, 0x728c, 0x9906, 0xdb68, 0xf46e], + &[0x1606, 0xbeca, 0xbe76, 0x860f, 0xdfa5], + &[0x8b4f, 0xde7a, 0xd220, 0x9fac, 0x2b6f], + &[0xb8fe, 0xebbe, 0xda32, 0x1a5f, 0x8b8b], + &[0x934b, 0x8956, 0xc434, 0x1881, 0xddf7], + &[0x5a95, 0x13fc, 0xf116, 0xd89b, 0x93f9], + &[0xd640, 0x71f1, 0xdd7d, 0x77eb, 0x1cd8], + &[0x348b, 0xaef0, 0xdb2c, 0xebf1, 0x1282], + &[0x50d7, 0xd824, 0x5010, 0xb369, 0x22ea]); } #[test] @@ -1453,22 +1453,22 @@ mod tests { fn test_truncate_utf16_at_nul() { let v = []; let b: &[u16] = &[]; - assert_eq!(truncate_utf16_at_nul(v), b); + assert_eq!(truncate_utf16_at_nul(&v), b); let v = [0, 2, 3]; - assert_eq!(truncate_utf16_at_nul(v), b); + assert_eq!(truncate_utf16_at_nul(&v), b); let v = [1, 0, 3]; let b: &[u16] = &[1]; - assert_eq!(truncate_utf16_at_nul(v), b); + assert_eq!(truncate_utf16_at_nul(&v), b); let v = [1, 2, 0]; let b: &[u16] = &[1, 2]; - assert_eq!(truncate_utf16_at_nul(v), b); + assert_eq!(truncate_utf16_at_nul(&v), b); let v = [1, 2, 3]; let b: &[u16] = &[1, 2, 3]; - assert_eq!(truncate_utf16_at_nul(v), b); + assert_eq!(truncate_utf16_at_nul(&v), b); } #[test] @@ -1582,7 +1582,7 @@ mod tests { fn test_chars_decoding() { let mut bytes = [0u8, ..4]; for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) { - let len = c.encode_utf8(bytes).unwrap_or(0); + let len = c.encode_utf8(&mut bytes).unwrap_or(0); let s = ::core::str::from_utf8(bytes[..len]).unwrap(); if Some(c) != s.chars().next() { panic!("character {:x}={} does not decode correctly", c as u32, c); @@ -1594,7 +1594,7 @@ mod tests { fn test_chars_rev_decoding() { let mut bytes = [0u8, ..4]; for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) { - let len = c.encode_utf8(bytes).unwrap_or(0); + let len = c.encode_utf8(&mut bytes).unwrap_or(0); let s = ::core::str::from_utf8(bytes[..len]).unwrap(); if Some(c) != s.chars().rev().next() { panic!("character {:x}={} does not decode correctly", c as u32, c); @@ -2111,20 +2111,20 @@ mod tests { let v: Vec<&str> = s.split_str(sep).collect(); assert_eq!(v.as_slice(), u.as_slice()); } - t("--1233345--", "12345", ["--1233345--"]); - t("abc::hello::there", "::", ["abc", "hello", "there"]); - t("::hello::there", "::", ["", "hello", "there"]); - t("hello::there::", "::", ["hello", "there", ""]); - t("::hello::there::", "::", ["", "hello", "there", ""]); - t("ประเทศไทย中华Việt Nam", "中华", ["ประเทศไทย", "Việt Nam"]); - t("zzXXXzzYYYzz", "zz", ["", "XXX", "YYY", ""]); - t("zzXXXzYYYz", "XXX", ["zz", "zYYYz"]); - t(".XXX.YYY.", ".", ["", "XXX", "YYY", ""]); - t("", ".", [""]); - t("zz", "zz", ["",""]); - t("ok", "z", ["ok"]); - t("zzz", "zz", ["","z"]); - t("zzzzz", "zz", ["","","z"]); + t("--1233345--", "12345", &["--1233345--"]); + t("abc::hello::there", "::", &["abc", "hello", "there"]); + t("::hello::there", "::", &["", "hello", "there"]); + t("hello::there::", "::", &["hello", "there", ""]); + t("::hello::there::", "::", &["", "hello", "there", ""]); + t("ประเทศไทย中华Việt Nam", "中华", &["ประเทศไทย", "Việt Nam"]); + t("zzXXXzzYYYzz", "zz", &["", "XXX", "YYY", ""]); + t("zzXXXzYYYz", "XXX", &["zz", "zYYYz"]); + t(".XXX.YYY.", ".", &["", "XXX", "YYY", ""]); + t("", ".", &[""]); + t("zz", "zz", &["",""]); + t("ok", "z", &["ok"]); + t("zzz", "zz", &["","z"]); + t("zzzzz", "zz", &["","","z"]); } #[test] @@ -2146,12 +2146,12 @@ mod tests { } let s = String::from_str("01234"); - assert_eq!(5, sum_len(["012", "", "34"])); - assert_eq!(5, sum_len([String::from_str("01").as_slice(), + assert_eq!(5, sum_len(&["012", "", "34"])); + assert_eq!(5, sum_len(&[String::from_str("01").as_slice(), String::from_str("2").as_slice(), String::from_str("34").as_slice(), String::from_str("").as_slice()])); - assert_eq!(5, sum_len([s.as_slice()])); + assert_eq!(5, sum_len(&[s.as_slice()])); } #[test]