Round 1 fixes and rebase conflicts

This commit is contained in:
Alex Crichton 2015-02-18 14:39:37 -08:00
parent b64dfff326
commit 365bd9a9e3
17 changed files with 44 additions and 44 deletions

View file

@ -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
}

View file

@ -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]

View file

@ -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; }

View file

@ -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;

View file

@ -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)

View file

@ -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()) }
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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\"");
}

View file

@ -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);
}

View file

@ -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 }
}

View file

@ -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);

View file

@ -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
}

View file

@ -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] {

View file

@ -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);
}

View file

@ -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,

View file

@ -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());
});