diff options
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/ascii.rs | 19 | ||||
| -rw-r--r-- | src/libstd/collections/hashmap/map.rs | 3 | ||||
| -rw-r--r-- | src/libstd/collections/hashmap/table.rs | 4 | ||||
| -rw-r--r-- | src/libstd/dynamic_lib.rs | 5 | ||||
| -rw-r--r-- | src/libstd/failure.rs | 4 | ||||
| -rw-r--r-- | src/libstd/io/buffered.rs | 10 | ||||
| -rw-r--r-- | src/libstd/io/comm_adapters.rs | 4 | ||||
| -rw-r--r-- | src/libstd/io/extensions.rs | 24 | ||||
| -rw-r--r-- | src/libstd/io/fs.rs | 4 | ||||
| -rw-r--r-- | src/libstd/io/net/ip.rs | 16 | ||||
| -rw-r--r-- | src/libstd/io/tempfile.rs | 2 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 1 | ||||
| -rw-r--r-- | src/libstd/os.rs | 57 | ||||
| -rw-r--r-- | src/libstd/path/mod.rs | 6 | ||||
| -rw-r--r-- | src/libstd/path/posix.rs | 6 | ||||
| -rw-r--r-- | src/libstd/path/windows.rs | 22 | ||||
| -rw-r--r-- | src/libstd/sync/task_pool.rs | 2 |
17 files changed, 101 insertions, 88 deletions
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index fd8432ded8b..fe2b8a15c73 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -21,8 +21,7 @@ use mem; use option::{Option, Some, None}; use slice::{ImmutableSlice, MutableSlice, Slice}; use str::{Str, StrSlice}; -use str; -use string::String; +use string::{mod, String}; use to_string::IntoStr; use vec::Vec; @@ -113,7 +112,7 @@ impl Ascii { /// Check if the character is a letter or number #[inline] pub fn is_alphanumeric(&self) -> bool { - self.is_alpha() || self.is_digit() + self.is_alphabetic() || self.is_digit() } /// Check if the character is a space or horizontal tab @@ -169,7 +168,7 @@ impl Ascii { /// Checks if the character is punctuation #[inline] pub fn is_punctuation(&self) -> bool { - self.is_graph() && !self.is_alnum() + self.is_graph() && !self.is_alphanumeric() } /// Checks if the character is a valid hex digit @@ -338,12 +337,12 @@ impl<'a> AsciiStr for &'a [Ascii] { #[inline] fn to_lower(&self) -> Vec<Ascii> { - self.iter().map(|a| a.to_lower()).collect() + self.iter().map(|a| a.to_lowercase()).collect() } #[inline] fn to_upper(&self) -> Vec<Ascii> { - self.iter().map(|a| a.to_upper()).collect() + self.iter().map(|a| a.to_uppercase()).collect() } #[inline] @@ -410,13 +409,13 @@ impl<'a> AsciiExt<String> for &'a str { #[inline] fn to_ascii_upper(&self) -> String { // Vec<u8>::to_ascii_upper() preserves the UTF-8 invariant. - unsafe { str::raw::from_utf8_owned(self.as_bytes().to_ascii_upper()) } + unsafe { string::raw::from_utf8(self.as_bytes().to_ascii_upper()) } } #[inline] fn to_ascii_lower(&self) -> String { // Vec<u8>::to_ascii_lower() preserves the UTF-8 invariant. - unsafe { str::raw::from_utf8_owned(self.as_bytes().to_ascii_lower()) } + unsafe { string::raw::from_utf8(self.as_bytes().to_ascii_lower()) } } #[inline] @@ -429,13 +428,13 @@ impl OwnedAsciiExt for String { #[inline] fn into_ascii_upper(self) -> String { // Vec<u8>::into_ascii_upper() preserves the UTF-8 invariant. - unsafe { str::raw::from_utf8_owned(self.into_bytes().into_ascii_upper()) } + unsafe { string::raw::from_utf8(self.into_bytes().into_ascii_upper()) } } #[inline] fn into_ascii_lower(self) -> String { // Vec<u8>::into_ascii_lower() preserves the UTF-8 invariant. - unsafe { str::raw::from_utf8_owned(self.into_bytes().into_ascii_lower()) } + unsafe { string::raw::from_utf8(self.into_bytes().into_ascii_lower()) } } } diff --git a/src/libstd/collections/hashmap/map.rs b/src/libstd/collections/hashmap/map.rs index e8c5eecc6f2..b0604e13163 100644 --- a/src/libstd/collections/hashmap/map.rs +++ b/src/libstd/collections/hashmap/map.rs @@ -1288,7 +1288,7 @@ impl<K: Eq + Hash<S>, V: Clone, S, H: Hasher<S>> HashMap<K, V, H> { /// let s: String = map.get_copy(&1); /// ``` pub fn get_copy(&self, k: &K) -> V { - (*self.get(k)).clone() + self[*k].clone() } } @@ -1325,6 +1325,7 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> Default for HashMap<K, V, H> impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> Index<K, V> for HashMap<K, V, H> { #[inline] + #[allow(deprecated)] fn index<'a>(&'a self, index: &K) -> &'a V { self.get(index) } diff --git a/src/libstd/collections/hashmap/table.rs b/src/libstd/collections/hashmap/table.rs index 87a5cc1484a..45ca633b41f 100644 --- a/src/libstd/collections/hashmap/table.rs +++ b/src/libstd/collections/hashmap/table.rs @@ -846,8 +846,8 @@ impl<K: Clone, V: Clone> Clone for RawTable<K, V> { (full.hash(), k.clone(), v.clone()) }; *new_buckets.raw.hash = h.inspect(); - mem::overwrite(new_buckets.raw.key, k); - mem::overwrite(new_buckets.raw.val, v); + ptr::write(new_buckets.raw.key, k); + ptr::write(new_buckets.raw.val, v); } Empty(..) => { *new_buckets.raw.hash = EMPTY_BUCKET; diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index 32e461b55b1..e8d570f30e6 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -281,6 +281,7 @@ pub mod dl { #[cfg(target_os = "windows")] pub mod dl { use c_str::ToCStr; + use collections::MutableSeq; use iter::Iterator; use libc; use os; @@ -295,8 +296,8 @@ pub mod dl { // Windows expects Unicode data let filename_cstr = filename.to_c_str(); let filename_str = str::from_utf8(filename_cstr.as_bytes_no_nul()).unwrap(); - let filename_str: Vec<u16> = filename_str.utf16_units().collect(); - let filename_str = filename_str.append_one(0); + let mut filename_str: Vec<u16> = filename_str.utf16_units().collect(); + filename_str.push(0); LoadLibraryW(filename_str.as_ptr() as *const libc::c_void) as *mut u8 } diff --git a/src/libstd/failure.rs b/src/libstd/failure.rs index 8d715de16e6..a7de84184ff 100644 --- a/src/libstd/failure.rs +++ b/src/libstd/failure.rs @@ -38,9 +38,9 @@ impl Writer for Stdio { } pub fn on_fail(obj: &Any + Send, file: &'static str, line: uint) { - let msg = match obj.as_ref::<&'static str>() { + let msg = match obj.downcast_ref::<&'static str>() { Some(s) => *s, - None => match obj.as_ref::<String>() { + None => match obj.downcast_ref::<String>() { Some(s) => s.as_slice(), None => "Box<Any>", } diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index a777a372ad1..d9543a06b35 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -162,7 +162,7 @@ impl<W: Writer> BufferedWriter<W> { fn flush_buf(&mut self) -> IoResult<()> { if self.pos != 0 { - let ret = self.inner.get_mut_ref().write(self.buf.slice_to(self.pos)); + let ret = self.inner.as_mut().unwrap().write(self.buf.slice_to(self.pos)); self.pos = 0; ret } else { @@ -174,7 +174,7 @@ impl<W: Writer> BufferedWriter<W> { /// /// This type does not expose the ability to get a mutable reference to the /// underlying reader because that could possibly corrupt the buffer. - pub fn get_ref<'a>(&'a self) -> &'a W { self.inner.get_ref() } + pub fn get_ref<'a>(&'a self) -> &'a W { self.inner.as_ref().unwrap() } /// Unwraps this `BufferedWriter`, returning the underlying writer. /// @@ -193,7 +193,7 @@ impl<W: Writer> Writer for BufferedWriter<W> { } if buf.len() > self.buf.len() { - self.inner.get_mut_ref().write(buf) + self.inner.as_mut().unwrap().write(buf) } else { let dst = self.buf.slice_from_mut(self.pos); slice::bytes::copy_memory(dst, buf); @@ -203,7 +203,7 @@ impl<W: Writer> Writer for BufferedWriter<W> { } fn flush(&mut self) -> IoResult<()> { - self.flush_buf().and_then(|()| self.inner.get_mut_ref().flush()) + self.flush_buf().and_then(|()| self.inner.as_mut().unwrap().flush()) } } @@ -273,7 +273,7 @@ impl<W> InternalBufferedWriter<W> { impl<W: Reader> Reader for InternalBufferedWriter<W> { fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { - self.get_mut().inner.get_mut_ref().read(buf) + self.get_mut().inner.as_mut().unwrap().read(buf) } } diff --git a/src/libstd/io/comm_adapters.rs b/src/libstd/io/comm_adapters.rs index f2ff5c7b5c2..0a969fc37c9 100644 --- a/src/libstd/io/comm_adapters.rs +++ b/src/libstd/io/comm_adapters.rs @@ -15,7 +15,7 @@ use comm::{Sender, Receiver}; use io; use option::{None, Option, Some}; use result::{Ok, Err}; -use slice::{bytes, MutableSlice, ImmutableSlice}; +use slice::{bytes, MutableSlice, ImmutableSlice, CloneableVector}; use str::StrSlice; use super::{Reader, Writer, IoResult}; use vec::Vec; @@ -118,7 +118,7 @@ impl Clone for ChanWriter { impl Writer for ChanWriter { fn write(&mut self, buf: &[u8]) -> IoResult<()> { - self.tx.send_opt(Vec::from_slice(buf)).map_err(|_| { + self.tx.send_opt(buf.to_vec()).map_err(|_| { io::IoError { kind: io::BrokenPipe, desc: "Pipe closed", diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index b61e7c6b441..a93f9826fa5 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -16,13 +16,14 @@ // FIXME: Iteration should probably be considered separately use collections::{Collection, MutableSeq}; +use io::{IoError, IoResult, Reader}; +use io; use iter::Iterator; +use num::Int; use option::{Option, Some, None}; +use ptr::RawPtr; use result::{Ok, Err}; -use io; -use io::{IoError, IoResult, Reader}; use slice::{ImmutableSlice, Slice}; -use ptr::RawPtr; /// An iterator that reads a single byte on each iteration, /// until `.read_byte()` returns `EndOfFile`. @@ -76,16 +77,15 @@ impl<'r, R: Reader> Iterator<IoResult<u8>> for Bytes<'r, R> { /// /// This function returns the value returned by the callback, for convenience. pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { - use mem::{to_le16, to_le32, to_le64}; use mem::transmute; // LLVM fails to properly optimize this when using shifts instead of the to_le* intrinsics assert!(size <= 8u); match size { 1u => f(&[n as u8]), - 2u => f(unsafe { transmute::<_, [u8, ..2]>(to_le16(n as u16)) }), - 4u => f(unsafe { transmute::<_, [u8, ..4]>(to_le32(n as u32)) }), - 8u => f(unsafe { transmute::<_, [u8, ..8]>(to_le64(n)) }), + 2u => f(unsafe { transmute::<_, [u8, ..2]>((n as u16).to_le()) }), + 4u => f(unsafe { transmute::<_, [u8, ..4]>((n as u32).to_le()) }), + 8u => f(unsafe { transmute::<_, [u8, ..8]>(n.to_le()) }), _ => { let mut bytes = vec!(); @@ -116,16 +116,15 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { /// /// This function returns the value returned by the callback, for convenience. pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { - use mem::{to_be16, to_be32, to_be64}; use mem::transmute; // LLVM fails to properly optimize this when using shifts instead of the to_be* intrinsics assert!(size <= 8u); match size { 1u => f(&[n as u8]), - 2u => f(unsafe { transmute::<_, [u8, ..2]>(to_be16(n as u16)) }), - 4u => f(unsafe { transmute::<_, [u8, ..4]>(to_be32(n as u32)) }), - 8u => f(unsafe { transmute::<_, [u8, ..8]>(to_be64(n)) }), + 2u => f(unsafe { transmute::<_, [u8, ..2]>((n as u16).to_be()) }), + 4u => f(unsafe { transmute::<_, [u8, ..4]>((n as u32).to_be()) }), + 8u => f(unsafe { transmute::<_, [u8, ..8]>(n.to_be()) }), _ => { let mut bytes = vec!(); let mut i = size; @@ -152,7 +151,6 @@ pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { /// 32-bit value is parsed. pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 { use ptr::{copy_nonoverlapping_memory}; - use mem::from_be64; use slice::MutableSlice; assert!(size <= 8u); @@ -166,7 +164,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 { let ptr = data.as_ptr().offset(start as int); let out = buf.as_mut_ptr(); copy_nonoverlapping_memory(out.offset((8 - size) as int), ptr, size); - from_be64(*(out as *const u64)) + (*(out as *const u64)).to_be() } } diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index f912b3ee38f..b8e18fc44cb 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -61,7 +61,7 @@ use io::{IoResult, IoError, FileStat, SeekStyle, Seek, Writer, Reader}; use io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append}; use io::UpdateIoError; use io; -use iter::Iterator; +use iter::{Iterator, Extendable}; use kinds::Send; use libc; use option::{Some, None, Option}; @@ -688,7 +688,7 @@ impl Iterator<Path> for Directories { e, path.display())); match result { - Ok(dirs) => { self.stack.push_all_move(dirs); } + Ok(dirs) => { self.stack.extend(dirs.into_iter()); } Err(..) => {} } } diff --git a/src/libstd/io/net/ip.rs b/src/libstd/io/net/ip.rs index 1141cd22eeb..6eb7d1c02fb 100644 --- a/src/libstd/io/net/ip.rs +++ b/src/libstd/io/net/ip.rs @@ -103,7 +103,12 @@ impl<'a> Parser<'a> { // Commit only if parser read till EOF fn read_till_eof<T>(&mut self, cb: |&mut Parser| -> Option<T>) -> Option<T> { - self.read_atomically(|p| cb(p).filtered(|_| p.is_eof())) + self.read_atomically(|p| { + match cb(p) { + Some(x) => if p.is_eof() {Some(x)} else {None}, + None => None, + } + }) } // Return result of first successful parser @@ -152,7 +157,10 @@ impl<'a> Parser<'a> { // Return char and advance iff next char is equal to requested fn read_given_char(&mut self, c: char) -> Option<char> { self.read_atomically(|p| { - p.read_char().filtered(|&next| next == c) + match p.read_char() { + Some(next) if next == c => Some(next), + _ => None, + } }) } @@ -232,8 +240,8 @@ impl<'a> Parser<'a> { fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> IpAddr { assert!(head.len() + tail.len() <= 8); let mut gs = [0u16, ..8]; - gs.copy_from(head); - gs.slice_mut(8 - tail.len(), 8).copy_from(tail); + gs.clone_from_slice(head); + gs.slice_mut(8 - tail.len(), 8).clone_from_slice(tail); Ipv6Addr(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7]) } diff --git a/src/libstd/io/tempfile.rs b/src/libstd/io/tempfile.rs index 6c9f10e19ae..9d6713b25b7 100644 --- a/src/libstd/io/tempfile.rs +++ b/src/libstd/io/tempfile.rs @@ -79,7 +79,7 @@ impl TempDir { /// Access the wrapped `std::path::Path` to the temporary directory. pub fn path<'a>(&'a self) -> &'a Path { - self.path.get_ref() + self.path.as_ref().unwrap() } /// Close and remove the temporary directory diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 23643542c4f..299e41f7219 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -112,7 +112,6 @@ // Don't link to std. We are std. #![no_std] -#![allow(deprecated)] #![deny(missing_doc)] #![reexport_test_harness_main = "test_main"] diff --git a/src/libstd/os.rs b/src/libstd/os.rs index f1480eb7d45..81dd114ec7d 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -46,15 +46,14 @@ use ptr::RawPtr; use ptr; use result::{Err, Ok, Result}; use slice::{Slice, ImmutableSlice, MutableSlice, ImmutablePartialEqSlice}; +use slice::CloneableVector; use str::{Str, StrSlice, StrAllocating}; use string::String; use sync::atomic::{AtomicInt, INIT_ATOMIC_INT, SeqCst}; use vec::Vec; -#[cfg(unix)] -use c_str::ToCStr; -#[cfg(unix)] -use libc::c_char; +#[cfg(unix)] use c_str::ToCStr; +#[cfg(unix)] use libc::c_char; /// Get the number of cores available pub fn num_cpus() -> uint { @@ -260,8 +259,11 @@ pub fn env_as_bytes() -> Vec<(Vec<u8>,Vec<u8>)> { let mut i = 0; while *ch.offset(i) != 0 { let p = &*ch.offset(i); - let len = ptr::position(p, |c| *c == 0); - raw::buf_as_slice(p, len, |s| { + let mut len = 0; + while *(p as *const _).offset(len) != 0 { + len += 1; + } + raw::buf_as_slice(p, len as uint, |s| { result.push(String::from_utf16_lossy(s).into_bytes()); }); i += len as int + 1; @@ -276,17 +278,18 @@ pub fn env_as_bytes() -> Vec<(Vec<u8>,Vec<u8>)> { extern { fn rust_env_pairs() -> *const *const c_char; } - let environ = rust_env_pairs(); + let mut environ = rust_env_pairs(); if environ as uint == 0 { fail!("os::env() failure getting env string from OS: {}", os::last_os_error()); } let mut result = Vec::new(); - ptr::array_each(environ, |e| { + while *environ != 0 as *const _ { let env_pair = - Vec::from_slice(CString::new(e, false).as_bytes_no_nul()); + CString::new(*environ, false).as_bytes_no_nul().to_vec(); result.push(env_pair); - }); + environ = environ.offset(1); + } result } @@ -294,9 +297,9 @@ pub fn env_as_bytes() -> Vec<(Vec<u8>,Vec<u8>)> { let mut pairs = Vec::new(); for p in input.iter() { let mut it = p.as_slice().splitn(1, |b| *b == b'='); - let key = Vec::from_slice(it.next().unwrap()); + let key = it.next().unwrap().to_vec(); let default: &[u8] = &[]; - let val = Vec::from_slice(it.next().unwrap_or(default)); + let val = it.next().unwrap_or(default).to_vec(); pairs.push((key, val)); } pairs @@ -350,8 +353,7 @@ pub fn getenv_as_bytes(n: &str) -> Option<Vec<u8>> { if s.is_null() { None } else { - Some(Vec::from_slice(CString::new(s as *const i8, - false).as_bytes_no_nul())) + Some(CString::new(s as *const i8, false).as_bytes_no_nul().to_vec()) } }) } @@ -364,8 +366,8 @@ pub fn getenv(n: &str) -> Option<String> { unsafe { with_env_lock(|| { use os::windows::{fill_utf16_buf_and_decode}; - let n: Vec<u16> = n.utf16_units().collect(); - let n = n.append_one(0); + let mut n: Vec<u16> = n.utf16_units().collect(); + n.push(0); fill_utf16_buf_and_decode(|buf, sz| { libc::GetEnvironmentVariableW(n.as_ptr(), buf, sz) }) @@ -411,10 +413,10 @@ pub fn setenv<T: BytesContainer>(n: &str, v: T) { #[cfg(windows)] fn _setenv(n: &str, v: &[u8]) { - let n: Vec<u16> = n.utf16_units().collect(); - let n = n.append_one(0); - let v: Vec<u16> = ::str::from_utf8(v).unwrap().utf16_units().collect(); - let v = v.append_one(0); + let mut n: Vec<u16> = n.utf16_units().collect(); + n.push(0); + let mut v: Vec<u16> = ::str::from_utf8(v).unwrap().utf16_units().collect(); + v.push(0); unsafe { with_env_lock(|| { @@ -441,8 +443,8 @@ pub fn unsetenv(n: &str) { #[cfg(windows)] fn _unsetenv(n: &str) { - let n: Vec<u16> = n.utf16_units().collect(); - let n = n.append_one(0); + let mut n: Vec<u16> = n.utf16_units().collect(); + n.push(0); unsafe { with_env_lock(|| { libc::SetEnvironmentVariableW(n.as_ptr(), ptr::null()); @@ -882,7 +884,11 @@ pub fn change_dir(p: &Path) -> bool { #[cfg(windows)] fn chdir(p: &Path) -> bool { let p = match p.as_str() { - Some(s) => s.utf16_units().collect::<Vec<u16>>().append_one(0), + Some(s) => { + let mut p = s.utf16_units().collect::<Vec<u16>>(); + p.push(0); + p + } None => return false, }; unsafe { @@ -1099,8 +1105,7 @@ unsafe fn load_argc_and_argv(argc: int, use c_str::CString; Vec::from_fn(argc as uint, |i| { - Vec::from_slice(CString::new(*argv.offset(i as int), - false).as_bytes_no_nul()) + CString::new(*argv.offset(i as int), false).as_bytes_no_nul().to_vec() }) } @@ -1169,7 +1174,7 @@ fn real_args_as_bytes() -> Vec<Vec<u8>> { mem::transmute(objc_msgSend(tmp, utf8Sel)); let s = CString::new(utf_c_str, false); if s.is_not_null() { - res.push(Vec::from_slice(s.as_bytes_no_nul())) + res.push(s.as_bytes_no_nul().to_vec()) } } } diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index d84848545bd..16552daae36 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -76,7 +76,7 @@ use option::{Option, None, Some}; use str; use str::{MaybeOwned, Str, StrSlice}; use string::String; -use slice::Slice; +use slice::{Slice, CloneableVector}; use slice::{ImmutablePartialEqSlice, ImmutableSlice}; use vec::Vec; @@ -480,7 +480,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { let extlen = extension.container_as_bytes().len(); match (name.rposition_elem(&dot), extlen) { (None, 0) | (Some(0), 0) => None, - (Some(idx), 0) => Some(Vec::from_slice(name.slice_to(idx))), + (Some(idx), 0) => Some(name.slice_to(idx).to_vec()), (idx, extlen) => { let idx = match idx { None | Some(0) => name.len(), @@ -798,7 +798,7 @@ pub trait BytesContainer { /// Consumes the receiver and converts it into Vec<u8> #[inline] fn container_into_owned_bytes(self) -> Vec<u8> { - Vec::from_slice(self.container_as_bytes()) + self.container_as_bytes().to_vec() } /// Returns the receiver interpreted as a utf-8 string, if possible #[inline] diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index c654d3a668a..9c4139853c5 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -264,7 +264,7 @@ impl GenericPath for Path { #[inline] fn is_absolute(&self) -> bool { - *self.repr.get(0) == SEP_BYTE + self.repr[0] == SEP_BYTE } fn is_ancestor_of(&self, other: &Path) -> bool { @@ -399,7 +399,7 @@ impl Path { } }; match val { - None => Vec::from_slice(v.as_slice()), + None => v.as_slice().to_vec(), Some(val) => val } } @@ -409,7 +409,7 @@ impl Path { /// /a/b/c and a/b/c yield the same set of components. /// A path of "/" yields no components. A path of "." yields one component. pub fn components<'a>(&'a self) -> Components<'a> { - let v = if *self.repr.get(0) == SEP_BYTE { + let v = if self.repr[0] == SEP_BYTE { self.repr.slice_from(1) } else { self.repr.as_slice() }; let mut ret = v.split(is_sep_byte); diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index e68c8bdb07d..3f598e52806 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -264,10 +264,10 @@ impl GenericPathUnsafe for Path { let repr = me.repr.as_slice(); match me.prefix { Some(DiskPrefix) => { - repr.as_bytes()[0] == path.as_bytes()[0].to_ascii().to_upper().to_byte() + repr.as_bytes()[0] == path.as_bytes()[0].to_ascii().to_uppercase().to_byte() } Some(VerbatimDiskPrefix) => { - repr.as_bytes()[4] == path.as_bytes()[0].to_ascii().to_upper().to_byte() + repr.as_bytes()[4] == path.as_bytes()[0].to_ascii().to_uppercase().to_byte() } _ => false } @@ -371,7 +371,7 @@ impl GenericPath for Path { #[inline] fn into_vec(self) -> Vec<u8> { - Vec::from_slice(self.repr.as_bytes()) + self.repr.into_bytes() } #[inline] @@ -776,9 +776,9 @@ impl Path { let mut s = String::from_str(s.slice_to(len)); unsafe { let v = s.as_mut_vec(); - *v.get_mut(0) = v.get(0) + *v.get_mut(0) = (*v)[0] .to_ascii() - .to_upper() + .to_uppercase() .to_byte(); } if is_abs { @@ -794,7 +794,7 @@ impl Path { let mut s = String::from_str(s.slice_to(len)); unsafe { let v = s.as_mut_vec(); - *v.get_mut(4) = v.get(4).to_ascii().to_upper().to_byte(); + *v.get_mut(4) = (*v)[4].to_ascii().to_uppercase().to_byte(); } Some(s) } @@ -815,12 +815,14 @@ impl Path { let mut s = String::with_capacity(n); match prefix { Some(DiskPrefix) => { - s.push_char(prefix_.as_bytes()[0].to_ascii().to_upper().to_char()); + s.push_char(prefix_.as_bytes()[0].to_ascii() + .to_uppercase().to_char()); s.push_char(':'); } Some(VerbatimDiskPrefix) => { s.push_str(prefix_.slice_to(4)); - s.push_char(prefix_.as_bytes()[4].to_ascii().to_upper().to_char()); + s.push_char(prefix_.as_bytes()[4].to_ascii() + .to_uppercase().to_char()); s.push_str(prefix_.slice_from(5)); } Some(UNCPrefix(a,b)) => { @@ -1619,7 +1621,7 @@ mod tests { t!(s: "a\\b\\c", ["d".to_string(), "e".to_string()], "a\\b\\c\\d\\e"); t!(v: b"a\\b\\c", [b"d", b"e"], b"a\\b\\c\\d\\e"); t!(v: b"a\\b\\c", [b"d", b"\\e", b"f"], b"\\e\\f"); - t!(v: b"a\\b\\c", [Vec::from_slice(b"d"), Vec::from_slice(b"e")], + t!(v: b"a\\b\\c", [b"d".to_vec(), b"e".to_vec()], b"a\\b\\c\\d\\e"); } @@ -1759,7 +1761,7 @@ mod tests { t!(s: "a\\b\\c", ["d", "\\e", "f"], "\\e\\f"); t!(s: "a\\b\\c", ["d".to_string(), "e".to_string()], "a\\b\\c\\d\\e"); t!(v: b"a\\b\\c", [b"d", b"e"], b"a\\b\\c\\d\\e"); - t!(v: b"a\\b\\c", [Vec::from_slice(b"d"), Vec::from_slice(b"e")], + t!(v: b"a\\b\\c", [b"d".to_vec(), b"e".to_vec()], b"a\\b\\c\\d\\e"); } diff --git a/src/libstd/sync/task_pool.rs b/src/libstd/sync/task_pool.rs index 23ba582ec0a..a00eeb1f938 100644 --- a/src/libstd/sync/task_pool.rs +++ b/src/libstd/sync/task_pool.rs @@ -79,7 +79,7 @@ impl<T> TaskPool<T> { /// Executes the function `f` on a task in the pool. The function /// receives a reference to the local data returned by the `init_fn`. pub fn execute(&mut self, f: proc(&T):Send) { - self.channels.get(self.next_index).send(Execute(f)); + self.channels[self.next_index].send(Execute(f)); self.next_index += 1; if self.next_index == self.channels.len() { self.next_index = 0; } } |
