about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmeliov Dmitrii <demelev1990@gmail.com>2015-03-30 19:22:46 +0300
committerEmeliov Dmitrii <demelev1990@gmail.com>2015-03-31 01:03:13 +0300
commitdf65f59fe9dd856c96a383c01067a176fee0dbb6 (patch)
tree25fd469f389b1a6739fd2fc8ea26b2d1aaf4fef8
parent6cf3b0b74aadcc1fe87adbd2c74876a1f6c920b3 (diff)
downloadrust-df65f59fe9dd856c96a383c01067a176fee0dbb6.tar.gz
rust-df65f59fe9dd856c96a383c01067a176fee0dbb6.zip
replace deprecated as_slice()
-rw-r--r--src/liballoc/arc.rs2
-rw-r--r--src/libcollections/slice.rs2
-rw-r--r--src/libcollections/str.rs6
-rw-r--r--src/libcollections/string.rs2
-rw-r--r--src/libcollections/vec.rs4
-rw-r--r--src/libcollections/vec_deque.rs3
-rw-r--r--src/libcollectionstest/fmt.rs2
-rw-r--r--src/libcollectionstest/slice.rs2
-rw-r--r--src/libcollectionstest/str.rs4
-rw-r--r--src/libcore/iter.rs8
-rw-r--r--src/libgraphviz/lib.rs2
-rw-r--r--src/librand/chacha.rs2
-rw-r--r--src/librand/lib.rs6
-rw-r--r--src/libserialize/json.rs2
-rw-r--r--src/libstd/fs/mod.rs4
-rw-r--r--src/libstd/io/cursor.rs8
-rw-r--r--src/libstd/old_io/fs.rs2
-rw-r--r--src/libstd/old_io/mem.rs2
-rw-r--r--src/libstd/old_io/net/ip.rs2
-rw-r--r--src/libstd/old_io/process.rs4
-rw-r--r--src/libstd/os.rs2
-rw-r--r--src/libstd/process.rs8
-rw-r--r--src/test/run-pass-fulldeps/compiler-calls.rs2
-rw-r--r--src/test/run-pass/regions-refcell.rs2
24 files changed, 41 insertions, 42 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs
index 9b37ddc7ab5..855c86f08e7 100644
--- a/src/liballoc/arc.rs
+++ b/src/liballoc/arc.rs
@@ -110,7 +110,7 @@ use heap::deallocate;
 ///         let child_numbers = shared_numbers.clone();
 ///
 ///         thread::spawn(move || {
-///             let local_numbers = child_numbers.as_slice();
+///             let local_numbers = &child_numbers[..];
 ///
 ///             // Work with the local numbers
 ///         });
diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs
index 14dcd52fe80..fb885d012c4 100644
--- a/src/libcollections/slice.rs
+++ b/src/libcollections/slice.rs
@@ -556,7 +556,6 @@ impl<T> [T] {
     /// ```rust
     /// # #![feature(core)]
     /// let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
-    /// let s = s.as_slice();
     ///
     /// let seek = 13;
     /// assert_eq!(s.binary_search_by(|probe| probe.cmp(&seek)), Ok(9));
@@ -923,7 +922,6 @@ impl<T> [T] {
     /// ```rust
     /// # #![feature(core)]
     /// let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
-    /// let s = s.as_slice();
     ///
     /// assert_eq!(s.binary_search(&13),  Ok(9));
     /// assert_eq!(s.binary_search(&4),   Err(7));
diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs
index 0665abc9e95..1e0a9adf760 100644
--- a/src/libcollections/str.rs
+++ b/src/libcollections/str.rs
@@ -1473,12 +1473,12 @@ impl str {
     /// let gr1 = "a\u{310}e\u{301}o\u{308}\u{332}".graphemes(true).collect::<Vec<&str>>();
     /// let b: &[_] = &["a\u{310}", "e\u{301}", "o\u{308}\u{332}"];
     ///
-    /// assert_eq!(gr1.as_slice(), b);
+    /// assert_eq!(&gr1[..], b);
     ///
     /// let gr2 = "a\r\nb🇷🇺🇸🇹".graphemes(true).collect::<Vec<&str>>();
     /// let b: &[_] = &["a", "\r\n", "b", "🇷🇺🇸🇹"];
     ///
-    /// assert_eq!(gr2.as_slice(), b);
+    /// assert_eq!(&gr2[..], b);
     /// ```
     #[unstable(feature = "unicode",
                reason = "this functionality may only be provided by libunicode")]
@@ -1496,7 +1496,7 @@ impl str {
     /// let gr_inds = "a̐éö̲\r\n".grapheme_indices(true).collect::<Vec<(usize, &str)>>();
     /// let b: &[_] = &[(0, "a̐"), (3, "é"), (6, "ö̲"), (11, "\r\n")];
     ///
-    /// assert_eq!(gr_inds.as_slice(), b);
+    /// assert_eq!(&gr_inds[..], b);
     /// ```
     #[unstable(feature = "unicode",
                reason = "this functionality may only be provided by libunicode")]
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs
index 7131c1cd881..6115f87951b 100644
--- a/src/libcollections/string.rs
+++ b/src/libcollections/string.rs
@@ -93,7 +93,7 @@ impl String {
     /// ```
     /// # #![feature(collections, core)]
     /// let s = String::from_str("hello");
-    /// assert_eq!(s.as_slice(), "hello");
+    /// assert_eq!(&s[..], "hello");
     /// ```
     #[inline]
     #[unstable(feature = "collections",
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index 14bc7f65e09..ec04e77790d 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -821,13 +821,13 @@ impl<T> Vec<T> {
     /// # #![feature(collections, core)]
     /// let v = vec![0, 1, 2];
     /// let w = v.map_in_place(|i| i + 3);
-    /// assert_eq!(w.as_slice(), [3, 4, 5].as_slice());
+    /// assert_eq!(&w[..], &[3, 4, 5]);
     ///
     /// #[derive(PartialEq, Debug)]
     /// struct Newtype(u8);
     /// let bytes = vec![0x11, 0x22];
     /// let newtyped_bytes = bytes.map_in_place(|x| Newtype(x));
-    /// assert_eq!(newtyped_bytes.as_slice(), [Newtype(0x11), Newtype(0x22)].as_slice());
+    /// assert_eq!(&newtyped_bytes[..], &[Newtype(0x11), Newtype(0x22)]);
     /// ```
     #[unstable(feature = "collections",
                reason = "API may change to provide stronger guarantees")]
diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs
index 8f3f4e6b890..3bdb85f3c4f 100644
--- a/src/libcollections/vec_deque.rs
+++ b/src/libcollections/vec_deque.rs
@@ -526,7 +526,8 @@ impl<T> VecDeque<T> {
     /// buf.push_back(3);
     /// buf.push_back(4);
     /// let b: &[_] = &[&5, &3, &4];
-    /// assert_eq!(buf.iter().collect::<Vec<&i32>>().as_slice(), b);
+    /// let c: Vec<&i32> = buf.iter().collect();
+    /// assert_eq!(&c[..], b);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn iter(&self) -> Iter<T> {
diff --git a/src/libcollectionstest/fmt.rs b/src/libcollectionstest/fmt.rs
index 9a9aa71b58b..abd1262dbf1 100644
--- a/src/libcollectionstest/fmt.rs
+++ b/src/libcollectionstest/fmt.rs
@@ -13,5 +13,5 @@ use std::fmt;
 #[test]
 fn test_format() {
     let s = fmt::format(format_args!("Hello, {}!", "world"));
-    assert_eq!(s.as_slice(), "Hello, world!");
+    assert_eq!(&s[..], "Hello, world!");
 }
diff --git a/src/libcollectionstest/slice.rs b/src/libcollectionstest/slice.rs
index 4168fe88a4b..24cafa9f1c6 100644
--- a/src/libcollectionstest/slice.rs
+++ b/src/libcollectionstest/slice.rs
@@ -59,7 +59,7 @@ fn test_from_elem() {
     // Test on-heap from_elem.
     v = vec![20; 6];
     {
-        let v = v.as_slice();
+        let v = &v[..];
         assert_eq!(v[0], 20);
         assert_eq!(v[1], 20);
         assert_eq!(v[2], 20);
diff --git a/src/libcollectionstest/str.rs b/src/libcollectionstest/str.rs
index 5cfa8009054..5b390befebe 100644
--- a/src/libcollectionstest/str.rs
+++ b/src/libcollectionstest/str.rs
@@ -1470,9 +1470,9 @@ fn test_split_strator() {
 fn test_str_default() {
     use std::default::Default;
 
-    fn t<S: Default + Str>() {
+    fn t<S: Default + AsRef<str>>() {
         let s: S = Default::default();
-        assert_eq!(s.as_slice(), "");
+        assert_eq!(s.as_ref(), "");
     }
 
     t::<&str>();
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs
index 39bf97ae1ce..6496aee2ea3 100644
--- a/src/libcore/iter.rs
+++ b/src/libcore/iter.rs
@@ -624,7 +624,7 @@ pub trait Iterator {
     /// let a = [1, 2, 3, 4, 5];
     /// let mut it = a.iter();
     /// assert!(it.any(|x| *x == 3));
-    /// assert_eq!(it.as_slice(), [4, 5]);
+    /// assert_eq!(&it[..], [4, 5]);
     ///
     /// ```
     #[inline]
@@ -648,7 +648,7 @@ pub trait Iterator {
     /// let a = [1, 2, 3, 4, 5];
     /// let mut it = a.iter();
     /// assert_eq!(it.find(|&x| *x == 3).unwrap(), &3);
-    /// assert_eq!(it.as_slice(), [4, 5]);
+    /// assert_eq!(&it[..], [4, 5]);
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn find<P>(&mut self, mut predicate: P) -> Option<Self::Item> where
@@ -672,7 +672,7 @@ pub trait Iterator {
     /// let a = [1, 2, 3, 4, 5];
     /// let mut it = a.iter();
     /// assert_eq!(it.position(|x| *x == 3).unwrap(), 2);
-    /// assert_eq!(it.as_slice(), [4, 5]);
+    /// assert_eq!(&it[..], [4, 5]);
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn position<P>(&mut self, mut predicate: P) -> Option<usize> where
@@ -702,7 +702,7 @@ pub trait Iterator {
     /// let a = [1, 2, 2, 4, 5];
     /// let mut it = a.iter();
     /// assert_eq!(it.rposition(|x| *x == 2).unwrap(), 2);
-    /// assert_eq!(it.as_slice(), [1, 2]);
+    /// assert_eq!(&it[..], [1, 2]);
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn rposition<P>(&mut self, mut predicate: P) -> Option<usize> where
diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs
index b3a3f266a5e..74be96235d2 100644
--- a/src/libgraphviz/lib.rs
+++ b/src/libgraphviz/lib.rs
@@ -84,7 +84,7 @@
 //!
 //!     fn edges(&'a self) -> dot::Edges<'a,Ed> {
 //!         let &Edges(ref edges) = self;
-//!         edges.as_slice().into_cow()
+//!         (&edges[..]).into_cow()
 //!     }
 //!
 //!     fn source(&self, e: &Ed) -> Nd { let &(s,_) = e; s }
diff --git a/src/librand/chacha.rs b/src/librand/chacha.rs
index 91abb548d2e..44187a4fc99 100644
--- a/src/librand/chacha.rs
+++ b/src/librand/chacha.rs
@@ -198,7 +198,7 @@ impl Rand for ChaChaRng {
         for word in &mut key {
             *word = other.gen();
         }
-        SeedableRng::from_seed(key.as_slice())
+        SeedableRng::from_seed(&key[..])
     }
 }
 
diff --git a/src/librand/lib.rs b/src/librand/lib.rs
index 97106908cde..7f7ab85e1db 100644
--- a/src/librand/lib.rs
+++ b/src/librand/lib.rs
@@ -153,7 +153,7 @@ pub trait Rng : Sized {
     ///
     /// let mut v = [0; 13579];
     /// thread_rng().fill_bytes(&mut v);
-    /// println!("{:?}", v.as_slice());
+    /// println!("{:?}", v);
     /// ```
     fn fill_bytes(&mut self, dest: &mut [u8]) {
         // this could, in theory, be done by transmuting dest to a
@@ -309,9 +309,9 @@ pub trait Rng : Sized {
     /// let mut rng = thread_rng();
     /// let mut y = [1, 2, 3];
     /// rng.shuffle(&mut y);
-    /// println!("{:?}", y.as_slice());
+    /// println!("{:?}", y);
     /// rng.shuffle(&mut y);
-    /// println!("{:?}", y.as_slice());
+    /// println!("{:?}", y);
     /// ```
     fn shuffle<T>(&mut self, values: &mut [T]) {
         let mut i = values.len();
diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs
index f6f059f7210..5cca41e3515 100644
--- a/src/libserialize/json.rs
+++ b/src/libserialize/json.rs
@@ -100,7 +100,7 @@
 //!     let encoded = json::encode(&object).unwrap();
 //!
 //!     // Deserialize using `json::decode`
-//!     let decoded: TestStruct = json::decode(encoded.as_slice()).unwrap();
+//!     let decoded: TestStruct = json::decode(&encoded[..]).unwrap();
 //! }
 //! ```
 //!
diff --git a/src/libstd/fs/mod.rs b/src/libstd/fs/mod.rs
index a3128ef0f8d..98c63d01e1a 100644
--- a/src/libstd/fs/mod.rs
+++ b/src/libstd/fs/mod.rs
@@ -1327,7 +1327,7 @@ mod tests {
         check!(fs::copy(&input, &out));
         let mut v = Vec::new();
         check!(check!(File::open(&out)).read_to_end(&mut v));
-        assert_eq!(v.as_slice(), b"hello");
+        assert_eq!(&v[..], b"hello");
 
         assert_eq!(check!(input.metadata()).permissions(),
                    check!(out.metadata()).permissions());
@@ -1622,7 +1622,7 @@ mod tests {
         check!(check!(File::create(&tmpdir.join("test"))).write(&bytes));
         let mut v = Vec::new();
         check!(check!(File::open(&tmpdir.join("test"))).read_to_end(&mut v));
-        assert!(v == bytes.as_slice());
+        assert!(v == &bytes[..]);
     }
 
     #[test]
diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs
index 79f0af670b4..10fe08fb688 100644
--- a/src/libstd/io/cursor.rs
+++ b/src/libstd/io/cursor.rs
@@ -282,19 +282,19 @@ mod tests {
     #[test]
     fn test_slice_reader() {
         let in_buf = vec![0, 1, 2, 3, 4, 5, 6, 7];
-        let mut reader = &mut in_buf.as_slice();
+        let mut reader = &mut &in_buf[..];
         let mut buf = [];
         assert_eq!(reader.read(&mut buf), Ok(0));
         let mut buf = [0];
         assert_eq!(reader.read(&mut buf), Ok(1));
         assert_eq!(reader.len(), 7);
         let b: &[_] = &[0];
-        assert_eq!(buf.as_slice(), b);
+        assert_eq!(buf, b);
         let mut buf = [0; 4];
         assert_eq!(reader.read(&mut buf), Ok(4));
         assert_eq!(reader.len(), 3);
         let b: &[_] = &[1, 2, 3, 4];
-        assert_eq!(buf.as_slice(), b);
+        assert_eq!(buf, b);
         assert_eq!(reader.read(&mut buf), Ok(3));
         let b: &[_] = &[5, 6, 7];
         assert_eq!(&buf[..3], b);
@@ -304,7 +304,7 @@ mod tests {
     #[test]
     fn test_buf_reader() {
         let in_buf = vec![0, 1, 2, 3, 4, 5, 6, 7];
-        let mut reader = Cursor::new(in_buf.as_slice());
+        let mut reader = Cursor::new(&in_buf[..]);
         let mut buf = [];
         assert_eq!(reader.read(&mut buf), Ok(0));
         assert_eq!(reader.position(), 0);
diff --git a/src/libstd/old_io/fs.rs b/src/libstd/old_io/fs.rs
index 6aa63c395c6..c5fd10a9e85 100644
--- a/src/libstd/old_io/fs.rs
+++ b/src/libstd/old_io/fs.rs
@@ -1639,7 +1639,7 @@ mod test {
 
         check!(File::create(&tmpdir.join("test")).write(&bytes));
         let actual = check!(File::open(&tmpdir.join("test")).read_to_end());
-        assert!(actual == bytes.as_slice());
+        assert!(actual == &bytes[..]);
     }
 
     #[test]
diff --git a/src/libstd/old_io/mem.rs b/src/libstd/old_io/mem.rs
index 5f20c383bb7..b03664ec0d0 100644
--- a/src/libstd/old_io/mem.rs
+++ b/src/libstd/old_io/mem.rs
@@ -744,7 +744,7 @@ mod test {
                     wr.write(&[5; 10]).unwrap();
                 }
             }
-            assert_eq!(buf.as_slice(), [5; 100].as_slice());
+            assert_eq!(buf.as_ref(), [5; 100].as_ref());
         });
     }
 
diff --git a/src/libstd/old_io/net/ip.rs b/src/libstd/old_io/net/ip.rs
index 26e1bb6550b..d405bde19cb 100644
--- a/src/libstd/old_io/net/ip.rs
+++ b/src/libstd/old_io/net/ip.rs
@@ -435,7 +435,7 @@ pub struct ParseError;
 ///     let tcp_l = TcpListener::bind("localhost:12345");
 ///
 ///     let mut udp_s = UdpSocket::bind(("127.0.0.1", 23451)).unwrap();
-///     udp_s.send_to([7, 7, 7].as_slice(), (Ipv4Addr(127, 0, 0, 1), 23451));
+///     udp_s.send_to([7, 7, 7].as_ref(), (Ipv4Addr(127, 0, 0, 1), 23451));
 /// }
 /// ```
 pub trait ToSocketAddr {
diff --git a/src/libstd/old_io/process.rs b/src/libstd/old_io/process.rs
index 06940bf6860..a2129fcde58 100644
--- a/src/libstd/old_io/process.rs
+++ b/src/libstd/old_io/process.rs
@@ -376,8 +376,8 @@ impl Command {
     /// };
     ///
     /// println!("status: {}", output.status);
-    /// println!("stdout: {}", String::from_utf8_lossy(output.output.as_slice()));
-    /// println!("stderr: {}", String::from_utf8_lossy(output.error.as_slice()));
+    /// println!("stdout: {}", String::from_utf8_lossy(output.output.as_ref()));
+    /// println!("stderr: {}", String::from_utf8_lossy(output.error.as_ref()));
     /// ```
     pub fn output(&self) -> IoResult<ProcessOutput> {
         self.spawn().and_then(|p| p.wait_with_output())
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index e19c734b8a3..2e3f47fea86 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -311,7 +311,7 @@ pub fn split_paths<T: BytesContainer>(unparsed: T) -> Vec<Path> {
 /// let key = "PATH";
 /// let mut paths = os::getenv_as_bytes(key).map_or(Vec::new(), os::split_paths);
 /// paths.push(Path::new("/home/xyz/bin"));
-/// os::setenv(key, os::join_paths(paths.as_slice()).unwrap());
+/// os::setenv(key, os::join_paths(&paths[..]).unwrap());
 /// ```
 #[unstable(feature = "os")]
 pub fn join_paths<T: BytesContainer>(paths: &[T]) -> Result<Vec<u8>, &'static str> {
diff --git a/src/libstd/process.rs b/src/libstd/process.rs
index b4bd513e8f0..7033ab5f09f 100644
--- a/src/libstd/process.rs
+++ b/src/libstd/process.rs
@@ -678,7 +678,7 @@ mod tests {
     fn test_process_output_output() {
         let Output {status, stdout, stderr}
              = Command::new("echo").arg("hello").output().unwrap();
-        let output_str = str::from_utf8(stdout.as_slice()).unwrap();
+        let output_str = str::from_utf8(&stdout[..]).unwrap();
 
         assert!(status.success());
         assert_eq!(output_str.trim().to_string(), "hello");
@@ -720,7 +720,7 @@ mod tests {
         let prog = Command::new("echo").arg("hello").stdout(Stdio::piped())
             .spawn().unwrap();
         let Output {status, stdout, stderr} = prog.wait_with_output().unwrap();
-        let output_str = str::from_utf8(stdout.as_slice()).unwrap();
+        let output_str = str::from_utf8(&stdout[..]).unwrap();
 
         assert!(status.success());
         assert_eq!(output_str.trim().to_string(), "hello");
@@ -855,7 +855,7 @@ mod tests {
             cmd.env("PATH", &p);
         }
         let result = cmd.output().unwrap();
-        let output = String::from_utf8_lossy(result.stdout.as_slice()).to_string();
+        let output = String::from_utf8_lossy(&result.stdout[..]).to_string();
 
         assert!(output.contains("RUN_TEST_NEW_ENV=123"),
                 "didn't find RUN_TEST_NEW_ENV inside of:\n\n{}", output);
@@ -864,7 +864,7 @@ mod tests {
     #[test]
     fn test_add_to_env() {
         let result = env_cmd().env("RUN_TEST_NEW_ENV", "123").output().unwrap();
-        let output = String::from_utf8_lossy(result.stdout.as_slice()).to_string();
+        let output = String::from_utf8_lossy(&result.stdout[..]).to_string();
 
         assert!(output.contains("RUN_TEST_NEW_ENV=123"),
                 "didn't find RUN_TEST_NEW_ENV inside of:\n\n{}", output);
diff --git a/src/test/run-pass-fulldeps/compiler-calls.rs b/src/test/run-pass-fulldeps/compiler-calls.rs
index 7a3c32a45f9..fdc670c6b71 100644
--- a/src/test/run-pass-fulldeps/compiler-calls.rs
+++ b/src/test/run-pass-fulldeps/compiler-calls.rs
@@ -77,6 +77,6 @@ fn main() {
     let mut tc = TestCalls { count: 1 };
     // we should never get use this filename, but lets make sure they are valid args.
     let args = vec!["compiler-calls".to_string(), "foo.rs".to_string()];
-    rustc_driver::run_compiler(args.as_slice(), &mut tc);
+    rustc_driver::run_compiler(&args[..], &mut tc);
     assert!(tc.count == 30);
 }
diff --git a/src/test/run-pass/regions-refcell.rs b/src/test/run-pass/regions-refcell.rs
index febf5f92ef6..63525b36206 100644
--- a/src/test/run-pass/regions-refcell.rs
+++ b/src/test/run-pass/regions-refcell.rs
@@ -29,7 +29,7 @@ fn foo<'a>(map: RefCell<HashMap<&'static str, &'a [u8]>>) {
 // supposed to match the lifetime `'a`) ...
 fn foo<'a>(map: RefCell<HashMap<&'static str, &'a [u8]>>) {
     let one = [1];
-    assert_eq!(map.borrow().get("one"), Some(&one.as_slice()));
+    assert_eq!(map.borrow().get("one"), Some(&&one[..]));
 }
 
 #[cfg(all(not(cannot_use_this_yet),not(cannot_use_this_yet_either)))]