diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs index d9c2290e68c..11c576eab15 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -925,7 +925,7 @@ impl Default for BitVec { #[stable(feature = "rust1", since = "1.0.0")] impl FromIterator<bool> for BitVec { fn from_iter<I: IntoIterator<Item=bool>>(iter: I) -> BitVec { - let mut ret = Bitv::new(); + let mut ret = BitVec::new(); ret.extend(iter); ret } @@ -1146,7 +1146,7 @@ impl Default for BitSet { #[stable(feature = "rust1", since = "1.0.0")] impl FromIterator<usize> for BitSet { fn from_iter<I: IntoIterator<Item=usize>>(iter: I) -> BitSet { - let mut ret = BitvSet::new(); + let mut ret = BitSet::new(); ret.extend(iter); ret } diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 7a6c3a00772..194c0dc4f28 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -522,11 +522,11 @@ pub trait IteratorExt: Iterator + Sized { /// /// let a = [1, 4, 2, 3, 8, 9, 6]; /// let sum = a.iter() - /// .cloned() - /// .inspect(|&x| println!("filtering {}", x)) - /// .filter(|&x| x % 2 == 0) - /// .inspect(|&x| println!("{} made it through", x)) - /// .sum(); + /// .map(|x| *x) + /// .inspect(|&x| println!("filtering {}", x)) + /// .filter(|&x| x % 2 == 0) + /// .inspect(|&x| println!("{} made it through", x)) + /// .sum(); /// println!("{}", sum); /// ``` #[inline] diff --git a/src/libcoretest/hash/mod.rs b/src/libcoretest/hash/mod.rs index 2d85769c0cd..9b6af182f72 100644 --- a/src/libcoretest/hash/mod.rs +++ b/src/libcoretest/hash/mod.rs @@ -23,7 +23,6 @@ impl Default for MyHasher { } impl Hasher for MyHasher { - type Output = u64; fn write(&mut self, buf: &[u8]) { for byte in buf { self.hash += *byte as u64; @@ -85,7 +84,6 @@ struct Custom { hash: u64 } struct CustomHasher { output: u64 } impl Hasher for CustomHasher { - type Output = u64; fn finish(&self) -> u64 { self.output } fn write(&mut self, data: &[u8]) { panic!() } fn write_u64(&mut self, data: u64) { self.output = data; } diff --git a/src/librustc_trans/trans/tvec.rs b/src/librustc_trans/trans/tvec.rs index 29a5d45a8be..7b59e0258ee 100644 --- a/src/librustc_trans/trans/tvec.rs +++ b/src/librustc_trans/trans/tvec.rs @@ -426,7 +426,7 @@ pub fn iter_vec_loop<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>, Br(bcx, loop_bcx.llbb, DebugLoc::None); let loop_counter = Phi(loop_bcx, bcx.ccx().int_type(), - &[C_uint(bcx.ccx(), 0)], &[bcx.llbb]); + &[C_uint(bcx.ccx(), 0 as usize)], &[bcx.llbb]); let bcx = loop_bcx; diff --git a/src/librustdoc/flock.rs b/src/librustdoc/flock.rs index eba915af519..ad91c3cb2c3 100644 --- a/src/librustdoc/flock.rs +++ b/src/librustdoc/flock.rs @@ -112,7 +112,7 @@ mod imp { impl Lock { pub fn new(p: &Path) -> Lock { - let buf = CString::from_slice(p.as_vec()).unwrap(); + let buf = CString::new(p.as_vec()).unwrap(); let fd = unsafe { libc::open(buf.as_ptr(), libc::O_RDWR | libc::O_CREAT, libc::S_IRWXU) diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 3ceaec5f53d..7ea5bd569e1 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -236,7 +236,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result { s.push_str(&highlight::highlight(&text, None, Some("rust-example-rendered"))); - let output = CString::from_vec(s.into_bytes()).unwrap(); + let output = CString::new(s).unwrap(); hoedown_buffer_puts(ob, output.as_ptr()); }) } @@ -293,7 +293,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result { format!("{} ", sec) }); - let text = CString::from_vec(text.into_bytes()).unwrap(); + let text = CString::new(text).unwrap(); unsafe { hoedown_buffer_puts(ob, text.as_ptr()) } } diff --git a/src/libstd/collections/hash/map_stage0.rs b/src/libstd/collections/hash/map_stage0.rs index 18241c7a0c3..8ae195cf991 100644 --- a/src/libstd/collections/hash/map_stage0.rs +++ b/src/libstd/collections/hash/map_stage0.rs @@ -1552,7 +1552,8 @@ impl<K, V, S, H> FromIterator<(K, V)> for HashMap<K, V, S> S: HashState<Hasher=H> + Default, H: hash::Hasher<Output=u64> { - fn from_iter<T: Iterator<Item=(K, V)>>(iter: T) -> HashMap<K, V, S> { + fn from_iter<T: IntoIterator<Item=(K, V)>>(iter: T) -> HashMap<K, V, S> { + let iter = iter.into_iter(); let lower = iter.size_hint().0; let mut map = HashMap::with_capacity_and_hash_state(lower, Default::default()); @@ -1567,7 +1568,7 @@ impl<K, V, S, H> Extend<(K, V)> for HashMap<K, V, S> S: HashState<Hasher=H>, H: hash::Hasher<Output=u64> { - fn extend<T: Iterator<Item=(K, V)>>(&mut self, iter: T) { + fn extend<T: IntoIterator<Item=(K, V)>>(&mut self, iter: T) { for (k, v) in iter { self.insert(k, v); } diff --git a/src/libstd/collections/hash/set_stage0.rs b/src/libstd/collections/hash/set_stage0.rs index 3bc22236a47..9d615d0c3ff 100644 --- a/src/libstd/collections/hash/set_stage0.rs +++ b/src/libstd/collections/hash/set_stage0.rs @@ -622,7 +622,8 @@ impl<T, S, H> FromIterator<T> for HashSet<T, S> S: HashState<Hasher=H> + Default, H: hash::Hasher<Output=u64> { - fn from_iter<I: Iterator<Item=T>>(iter: I) -> HashSet<T, S> { + fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> HashSet<T, S> { + let iter = iter.into_iter(); let lower = iter.size_hint().0; let mut set = HashSet::with_capacity_and_hash_state(lower, Default::default()); set.extend(iter); @@ -636,7 +637,7 @@ impl<T, S, H> Extend<T> for HashSet<T, S> S: HashState<Hasher=H>, H: hash::Hasher<Output=u64> { - fn extend<I: Iterator<Item=T>>(&mut self, iter: I) { + fn extend<I: IntoIterator<Item=T>>(&mut self, iter: I) { for k in iter { self.insert(k); } diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 70c14ef1978..8976813d3f9 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -105,7 +105,7 @@ pub struct CString { /// } /// /// fn main() { -/// let s = CString::from_slice(b"data data data data").unwrap(); +/// let s = CString::new("data data data data").unwrap(); /// work(&s); /// } /// ``` @@ -141,7 +141,7 @@ impl CString { /// extern { fn puts(s: *const libc::c_char); } /// /// fn main() { - /// let to_print = CString::from_slice(b"Hello!").unwrap(); + /// let to_print = CString::new("Hello!").unwrap(); /// unsafe { /// puts(to_print.as_ptr()); /// } @@ -175,7 +175,7 @@ impl CString { /// extern { fn puts(s: *const libc::c_char); } /// /// fn main() { - /// let to_print = CString::from_slice(b"Hello!").unwrap(); + /// let to_print = CString::new("Hello!").unwrap(); /// unsafe { /// puts(to_print.as_ptr()); /// } @@ -436,18 +436,18 @@ mod tests { #[test] fn simple() { - let s = CString::from_slice(b"1234").unwrap(); + let s = CString::new(b"1234").unwrap(); assert_eq!(s.as_bytes(), b"1234"); assert_eq!(s.as_bytes_with_nul(), b"1234\0"); } #[test] fn build_with_zero1() { - assert!(CString::from_slice(b"\0").is_err()); + assert!(CString::new(b"\0").is_err()); } #[test] fn build_with_zero2() { - assert!(CString::from_vec(vec![0]).is_err()); + assert!(CString::new(vec![0]).is_err()); } #[test] @@ -460,7 +460,7 @@ mod tests { #[test] fn formatted() { - let s = CString::from_slice(b"12").unwrap(); + let s = CString::new(b"12").unwrap(); assert_eq!(format!("{:?}", s), "\"12\""); } diff --git a/src/test/run-pass/bitv-perf-test.rs b/src/test/run-pass/bitv-perf-test.rs index b6d428924e3..7bb9f042fe8 100644 --- a/src/test/run-pass/bitv-perf-test.rs +++ b/src/test/run-pass/bitv-perf-test.rs @@ -13,11 +13,11 @@ #![feature(box_syntax)] extern crate collections; -use std::collections::Bitv; +use std::collections::BitVec; fn bitv_test() { - let mut v1 = box Bitv::from_elem(31, false); - let v2 = box Bitv::from_elem(31, true); + let mut v1 = box BitVec::from_elem(31, false); + let v2 = box BitVec::from_elem(31, true); v1.union(&*v2); } diff --git a/src/test/run-pass/c-stack-returning-int64.rs b/src/test/run-pass/c-stack-returning-int64.rs index d18a3055b9c..6246ee9c6c4 100644 --- a/src/test/run-pass/c-stack-returning-int64.rs +++ b/src/test/run-pass/c-stack-returning-int64.rs @@ -24,12 +24,12 @@ mod mlibc { } fn atol(s: String) -> int { - let c = CString::from_slice(s.as_bytes()).unwrap(); + let c = CString::new(s).unwrap(); unsafe { mlibc::atol(c.as_ptr()) as int } } fn atoll(s: String) -> i64 { - let c = CString::from_slice(s.as_bytes()).unwrap(); + let c = CString::new(s).unwrap(); unsafe { mlibc::atoll(c.as_ptr()) as i64 } } diff --git a/src/test/run-pass/const-polymorphic-paths.rs b/src/test/run-pass/const-polymorphic-paths.rs index f8f92a56adb..e9d10536b75 100644 --- a/src/test/run-pass/const-polymorphic-paths.rs +++ b/src/test/run-pass/const-polymorphic-paths.rs @@ -11,7 +11,7 @@ #![feature(macro_rules)] use std::borrow::{Cow, IntoCow}; -use std::collections::Bitv; +use std::collections::BitVec; use std::default::Default; use std::iter::FromIterator; use std::ops::Add; @@ -63,8 +63,8 @@ tests! { Vec::<()>::new, fn() -> Vec<()>, (); Vec::with_capacity, fn(uint) -> Vec<()>, (5); Vec::<()>::with_capacity, fn(uint) -> Vec<()>, (5); - Bitv::from_fn, fn(uint, fn(uint) -> bool) -> Bitv, (5, odd); - Bitv::from_fn::<fn(uint) -> bool>, fn(uint, fn(uint) -> bool) -> Bitv, (5, odd); + BitVec::from_fn, fn(uint, fn(uint) -> bool) -> BitVec, (5, odd); + BitVec::from_fn::<fn(uint) -> bool>, fn(uint, fn(uint) -> bool) -> BitVec, (5, odd); // Inherent non-static method. Vec::map_in_place, fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>, (vec![b'f', b'o', b'o'], u8_as_i8); diff --git a/src/test/run-pass/foreign-fn-linkname.rs b/src/test/run-pass/foreign-fn-linkname.rs index 69e5b9f43ea..24b711328a1 100644 --- a/src/test/run-pass/foreign-fn-linkname.rs +++ b/src/test/run-pass/foreign-fn-linkname.rs @@ -24,7 +24,7 @@ mod mlibc { fn strlen(str: String) -> uint { // C string is terminated with a zero - let s = CString::from_slice(str.as_bytes()).unwrap(); + let s = CString::new(str).unwrap(); unsafe { mlibc::my_strlen(s.as_ptr()) as uint } diff --git a/src/test/run-pass/issue-11736.rs b/src/test/run-pass/issue-11736.rs index d9bae6886fa..b901e95ff55 100644 --- a/src/test/run-pass/issue-11736.rs +++ b/src/test/run-pass/issue-11736.rs @@ -10,13 +10,13 @@ extern crate collections; -use std::collections::Bitv; +use std::collections::BitVec; use std::num::Float; fn main() { // Generate sieve of Eratosthenes for n up to 1e6 let n = 1000000_usize; - let mut sieve = Bitv::from_elem(n+1, true); + let mut sieve = BitVec::from_elem(n+1, true); let limit: uint = (n as f32).sqrt() as uint; for i in 2..limit+1 { if sieve[i] { diff --git a/src/test/run-pass/issue-2383.rs b/src/test/run-pass/issue-2383.rs index b8136323df6..a5a05283f80 100644 --- a/src/test/run-pass/issue-2383.rs +++ b/src/test/run-pass/issue-2383.rs @@ -10,9 +10,9 @@ // except according to those terms. extern crate collections; -use std::collections::RingBuf; +use std::collections::VecDeque; pub fn main() { - let mut q = RingBuf::new(); + let mut q = VecDeque::new(); q.push_front(10); } diff --git a/src/test/run-pass/rename-directory.rs b/src/test/run-pass/rename-directory.rs index 54e0e2de242..abe6ffe7d4c 100644 --- a/src/test/run-pass/rename-directory.rs +++ b/src/test/run-pass/rename-directory.rs @@ -31,12 +31,12 @@ fn rename_directory() { let test_file = &old_path.join("temp.txt"); /* Write the temp input file */ - let fromp = CString::from_slice(test_file.as_vec()).unwrap(); - let modebuf = CString::from_slice(b"w+b").unwrap(); + let fromp = CString::new(test_file.as_vec()).unwrap(); + let modebuf = CString::new(b"w+b").unwrap(); let ostream = libc::fopen(fromp.as_ptr(), modebuf.as_ptr()); assert!((ostream as uint != 0_usize)); let s = "hello".to_string(); - let buf = CString::from_slice(b"hello").unwrap(); + let buf = CString::new(b"hello").unwrap(); let write_len = libc::fwrite(buf.as_ptr() as *mut _, 1_usize as libc::size_t, (s.len() + 1_usize) as libc::size_t, diff --git a/src/test/run-pass/variadic-ffi.rs b/src/test/run-pass/variadic-ffi.rs index 85f6ef0ddcd..5a476ed9ee2 100644 --- a/src/test/run-pass/variadic-ffi.rs +++ b/src/test/run-pass/variadic-ffi.rs @@ -29,11 +29,11 @@ pub fn main() { unsafe { // Call with just the named parameter - let c = CString::from_slice(b"Hello World\n").unwrap(); + let c = CString::new(b"Hello World\n").unwrap(); check("Hello World\n", |s| sprintf(s, c.as_ptr())); // Call with variable number of arguments - let c = CString::from_slice(b"%d %f %c %s\n").unwrap(); + let c = CString::new(b"%d %f %c %s\n").unwrap(); check("42 42.500000 a %d %f %c %s\n\n", |s| { sprintf(s, c.as_ptr(), 42, 42.5f64, 'a' as c_int, c.as_ptr()); }); @@ -44,11 +44,11 @@ pub fn main() { // A function that takes a function pointer unsafe fn call(p: unsafe extern fn(*mut c_char, *const c_char, ...) -> c_int) { // Call with just the named parameter - let c = CString::from_slice(b"Hello World\n").unwrap(); + let c = CString::new(b"Hello World\n").unwrap(); check("Hello World\n", |s| sprintf(s, c.as_ptr())); // Call with variable number of arguments - let c = CString::from_slice(b"%d %f %c %s\n").unwrap(); + let c = CString::new(b"%d %f %c %s\n").unwrap(); check("42 42.500000 a %d %f %c %s\n\n", |s| { sprintf(s, c.as_ptr(), 42, 42.5f64, 'a' as c_int, c.as_ptr()); });