Skip to content
2 changes: 1 addition & 1 deletion doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -2620,7 +2620,7 @@ assert!(b != "world");

The vector type constructor represents a homogeneous array of values of a given type.
A vector has a fixed size.
(Operations like `vec::push` operate solely on owned vectors.)
(Operations like `vec.push` operate solely on owned vectors.)
A vector type can be annotated with a _definite_ size,
written with a trailing asterisk and integer literal, such as `[int * 10]`.
Such a definite-sized vector type is a first-class type, since its size is known statically.
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub fn parse_config(args: ~[~str]) -> config {
];

assert!(!args.is_empty());
let args_ = vec::tail(args);
let args_ = args.tail();
let matches =
&match getopts::getopts(args_, opts) {
Ok(m) => m,
Expand Down
3 changes: 1 addition & 2 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,7 @@ fn check_error_patterns(props: &TestProps,
if done { return; }

let missing_patterns =
vec::slice(props.error_patterns, next_err_idx,
props.error_patterns.len());
props.error_patterns.slice(next_err_idx, props.error_patterns.len());
if missing_patterns.len() == 1u {
fatal_ProcRes(fmt!("error pattern '%s' not found!",
missing_patterns[0]), ProcRes);
Expand Down
1 change: 0 additions & 1 deletion src/libextra/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,6 @@ mod tests {

use arc::*;

use core::vec;
use core::cell::Cell;
use core::comm;
use core::task;
Expand Down
3 changes: 1 addition & 2 deletions src/libextra/c_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ mod tests {

assert!(mem as int != 0);

return c_vec_with_dtor(mem as *mut u8, n as uint,
|| unsafe { free(mem) });
c_vec_with_dtor(mem as *mut u8, n as uint, || free(mem))
}
}

Expand Down
79 changes: 39 additions & 40 deletions src/libextra/crypto/sha2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use core::prelude::*;

use core::uint;
use core::vec;

use digest::Digest;

Expand Down Expand Up @@ -118,7 +117,7 @@ impl Engine512 {
}

while in.len() - i >= 8 {
let w = to_u64(vec::slice(in, i, i + 8));
let w = to_u64(in.slice(i, i + 8));
self.process_word(w);
self.bit_counter.add_bytes(8);
i += 8;
Expand Down Expand Up @@ -274,43 +273,43 @@ impl Engine512 {
fn result_512(&mut self, out: &mut [u8]) {
self.finish();

from_u64(self.H0, vec::mut_slice(out, 0, 8));
from_u64(self.H1, vec::mut_slice(out, 8, 16));
from_u64(self.H2, vec::mut_slice(out, 16, 24));
from_u64(self.H3, vec::mut_slice(out, 24, 32));
from_u64(self.H4, vec::mut_slice(out, 32, 40));
from_u64(self.H5, vec::mut_slice(out, 40, 48));
from_u64(self.H6, vec::mut_slice(out, 48, 56));
from_u64(self.H7, vec::mut_slice(out, 56, 64));
from_u64(self.H0, out.mut_slice(0, 8));
from_u64(self.H1, out.mut_slice(8, 16));
from_u64(self.H2, out.mut_slice(16, 24));
from_u64(self.H3, out.mut_slice(24, 32));
from_u64(self.H4, out.mut_slice(32, 40));
from_u64(self.H5, out.mut_slice(40, 48));
from_u64(self.H6, out.mut_slice(48, 56));
from_u64(self.H7, out.mut_slice(56, 64));
}

fn result_384(&mut self, out: &mut [u8]) {
self.finish();

from_u64(self.H0, vec::mut_slice(out, 0, 8));
from_u64(self.H1, vec::mut_slice(out, 8, 16));
from_u64(self.H2, vec::mut_slice(out, 16, 24));
from_u64(self.H3, vec::mut_slice(out, 24, 32));
from_u64(self.H4, vec::mut_slice(out, 32, 40));
from_u64(self.H5, vec::mut_slice(out, 40, 48));
from_u64(self.H0, out.mut_slice(0, 8));
from_u64(self.H1, out.mut_slice(8, 16));
from_u64(self.H2, out.mut_slice(16, 24));
from_u64(self.H3, out.mut_slice(24, 32));
from_u64(self.H4, out.mut_slice(32, 40));
from_u64(self.H5, out.mut_slice(40, 48));
}

fn result_256(&mut self, out: &mut [u8]) {
self.finish();

from_u64(self.H0, vec::mut_slice(out, 0, 8));
from_u64(self.H1, vec::mut_slice(out, 8, 16));
from_u64(self.H2, vec::mut_slice(out, 16, 24));
from_u64(self.H3, vec::mut_slice(out, 24, 32));
from_u64(self.H0, out.mut_slice(0, 8));
from_u64(self.H1, out.mut_slice(8, 16));
from_u64(self.H2, out.mut_slice(16, 24));
from_u64(self.H3, out.mut_slice(24, 32));
}

fn result_224(&mut self, out: &mut [u8]) {
self.finish();

from_u64(self.H0, vec::mut_slice(out, 0, 8));
from_u64(self.H1, vec::mut_slice(out, 8, 16));
from_u64(self.H2, vec::mut_slice(out, 16, 24));
from_u32((self.H3 >> 32) as u32, vec::mut_slice(out, 24, 28));
from_u64(self.H0, out.mut_slice(0, 8));
from_u64(self.H1, out.mut_slice(8, 16));
from_u64(self.H2, out.mut_slice(16, 24));
from_u32((self.H3 >> 32) as u32, out.mut_slice(24, 28));
}
}

Expand Down Expand Up @@ -400,7 +399,7 @@ impl Engine256 {
}

while in.len() - i >= 4 {
let w = to_u32(vec::slice(in, i, i + 4));
let w = to_u32(in.slice(i, i + 4));
self.process_word(w);
self.length_bytes += 4;
i += 4;
Expand Down Expand Up @@ -556,26 +555,26 @@ impl Engine256 {
fn result_256(&mut self, out: &mut [u8]) {
self.finish();

from_u32(self.H0, vec::mut_slice(out, 0, 4));
from_u32(self.H1, vec::mut_slice(out, 4, 8));
from_u32(self.H2, vec::mut_slice(out, 8, 12));
from_u32(self.H3, vec::mut_slice(out, 12, 16));
from_u32(self.H4, vec::mut_slice(out, 16, 20));
from_u32(self.H5, vec::mut_slice(out, 20, 24));
from_u32(self.H6, vec::mut_slice(out, 24, 28));
from_u32(self.H7, vec::mut_slice(out, 28, 32));
from_u32(self.H0, out.mut_slice(0, 4));
from_u32(self.H1, out.mut_slice(4, 8));
from_u32(self.H2, out.mut_slice(8, 12));
from_u32(self.H3, out.mut_slice(12, 16));
from_u32(self.H4, out.mut_slice(16, 20));
from_u32(self.H5, out.mut_slice(20, 24));
from_u32(self.H6, out.mut_slice(24, 28));
from_u32(self.H7, out.mut_slice(28, 32));
}

fn result_224(&mut self, out: &mut [u8]) {
self.finish();

from_u32(self.H0, vec::mut_slice(out, 0, 4));
from_u32(self.H1, vec::mut_slice(out, 4, 8));
from_u32(self.H2, vec::mut_slice(out, 8, 12));
from_u32(self.H3, vec::mut_slice(out, 12, 16));
from_u32(self.H4, vec::mut_slice(out, 16, 20));
from_u32(self.H5, vec::mut_slice(out, 20, 24));
from_u32(self.H6, vec::mut_slice(out, 24, 28));
from_u32(self.H0, out.mut_slice(0, 4));
from_u32(self.H1, out.mut_slice(4, 8));
from_u32(self.H2, out.mut_slice(8, 12));
from_u32(self.H3, out.mut_slice(12, 16));
from_u32(self.H4, out.mut_slice(16, 20));
from_u32(self.H5, out.mut_slice(20, 24));
from_u32(self.H6, out.mut_slice(24, 28));
}
}

Expand Down
13 changes: 6 additions & 7 deletions src/libextra/deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl<T> Deque<T> {
///
/// * n - The number of elements to reserve space for
pub fn reserve(&mut self, n: uint) {
vec::reserve(&mut self.elts, n);
self.elts.reserve(n);
}

/// Reserve capacity for at least `n` elements in the given deque,
Expand All @@ -151,7 +151,7 @@ impl<T> Deque<T> {
///
/// * n - The number of elements to reserve space for
pub fn reserve_at_least(&mut self, n: uint) {
vec::reserve_at_least(&mut self.elts, n);
self.elts.reserve_at_least(n);
}

/// Front-to-back iterator.
Expand Down Expand Up @@ -256,7 +256,6 @@ mod tests {
use super::*;
use core::cmp::Eq;
use core::kinds::Copy;
use core::vec::capacity;
use core;

#[test]
Expand Down Expand Up @@ -442,23 +441,23 @@ mod tests {
let mut d = Deque::new();
d.add_back(0u64);
d.reserve(50);
assert_eq!(capacity(&mut d.elts), 50);
assert_eq!(d.elts.capacity(), 50);
let mut d = Deque::new();
d.add_back(0u32);
d.reserve(50);
assert_eq!(capacity(&mut d.elts), 50);
assert_eq!(d.elts.capacity(), 50);
}

#[test]
fn test_reserve_at_least() {
let mut d = Deque::new();
d.add_back(0u64);
d.reserve_at_least(50);
assert_eq!(capacity(&mut d.elts), 64);
assert_eq!(d.elts.capacity(), 64);
let mut d = Deque::new();
d.add_back(0u32);
d.reserve_at_least(50);
assert_eq!(capacity(&mut d.elts), 64);
assert_eq!(d.elts.capacity(), 64);
}

#[test]
Expand Down
2 changes: 0 additions & 2 deletions src/libextra/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,6 @@ mod tests {

use super::*;

use core::vec;

#[test]
fn test_dlist_concat() {
let a = from_vec([1,2]);
Expand Down
3 changes: 1 addition & 2 deletions src/libextra/ebml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ pub mod reader {
use core::ptr::offset;
use core::str;
use core::unstable::intrinsics::bswap32;
use core::vec;

// ebml reading

Expand Down Expand Up @@ -248,7 +247,7 @@ pub mod reader {
}

pub fn with_doc_data<T>(d: Doc, f: &fn(x: &[u8]) -> T) -> T {
f(vec::slice(*d.data, d.start, d.end))
f(d.data.slice(d.start, d.end))
}


Expand Down
24 changes: 6 additions & 18 deletions src/libextra/net_tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -976,9 +976,7 @@ impl io::Writer for TcpSocketBuf {
let socket_data_ptr: *TcpSocketData =
&(*((*(self.data)).sock).socket_data);
let w_result = write_common_impl(socket_data_ptr,
vec::slice(data,
0,
data.len()).to_owned());
data.slice(0, data.len()).to_owned());
if w_result.is_err() {
let err_data = w_result.get_err();
debug!(
Expand Down Expand Up @@ -1459,33 +1457,23 @@ mod test {

#[test]
fn test_gl_tcp_server_and_client_ipv4() {
unsafe {
impl_gl_tcp_ipv4_server_and_client();
}
impl_gl_tcp_ipv4_server_and_client();
}
#[test]
fn test_gl_tcp_get_peer_addr() {
unsafe {
impl_gl_tcp_ipv4_get_peer_addr();
}
impl_gl_tcp_ipv4_get_peer_addr();
}
#[test]
fn test_gl_tcp_ipv4_client_error_connection_refused() {
unsafe {
impl_gl_tcp_ipv4_client_error_connection_refused();
}
impl_gl_tcp_ipv4_client_error_connection_refused();
}
#[test]
fn test_gl_tcp_server_address_in_use() {
unsafe {
impl_gl_tcp_ipv4_server_address_in_use();
}
impl_gl_tcp_ipv4_server_address_in_use();
}
#[test]
fn test_gl_tcp_server_access_denied() {
unsafe {
impl_gl_tcp_ipv4_server_access_denied();
}
impl_gl_tcp_ipv4_server_access_denied();
}
// Strange failure on Windows. --pcwalton
#[test]
Expand Down
17 changes: 8 additions & 9 deletions src/libextra/num/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,8 @@ impl Mul<BigUint, BigUint> for BigUint {

fn cut_at(a: &BigUint, n: uint) -> (BigUint, BigUint) {
let mid = uint::min(a.data.len(), n);
return (BigUint::from_slice(vec::slice(a.data, mid,
a.data.len())),
BigUint::from_slice(vec::slice(a.data, 0, mid)));
return (BigUint::from_slice(a.data.slice(mid, a.data.len())),
BigUint::from_slice(a.data.slice(0, mid)));
}


Expand Down Expand Up @@ -413,7 +412,7 @@ impl Integer for BigUint {
return (Zero::zero(), Zero::zero(), copy *a);
}

let an = vec::slice(a.data, a.data.len() - n, a.data.len());
let an = a.data.slice(a.data.len() - n, a.data.len());
let bn = *b.data.last();
let mut d = ~[];
let mut carry = 0;
Expand Down Expand Up @@ -578,7 +577,7 @@ impl BigUint {
let mut power: BigUint = One::one();
loop {
let start = uint::max(end, unit_len) - unit_len;
match uint::parse_bytes(vec::slice(buf, start, end), radix) {
match uint::parse_bytes(buf.slice(start, end), radix) {
// FIXME(#6102): Assignment operator for BigInt causes ICE
// Some(d) => n += BigUint::from_uint(d) * power,
Some(d) => n = n + BigUint::from_uint(d) * power,
Expand Down Expand Up @@ -634,7 +633,7 @@ impl BigUint {
if n_unit == 0 { return copy *self; }
if self.data.len() < n_unit { return Zero::zero(); }
return BigUint::from_slice(
vec::slice(self.data, n_unit, self.data.len())
self.data.slice(n_unit, self.data.len())
);
}

Expand Down Expand Up @@ -1132,7 +1131,7 @@ impl BigInt {
sign = Minus;
start = 1;
}
return BigUint::parse_bytes(vec::slice(buf, start, buf.len()), radix)
return BigUint::parse_bytes(buf.slice(start, buf.len()), radix)
.map_consume(|bu| BigInt::from_biguint(sign, bu));
}
Expand Down Expand Up @@ -1176,7 +1175,7 @@ mod biguint_tests {
let data = [ &[], &[1], &[2], &[-1], &[0, 1], &[2, 1], &[1, 1, 1] ]
.map(|v| BigUint::from_slice(*v));
for data.iter().enumerate().advance |(i, ni)| {
for vec::slice(data, i, data.len()).iter().enumerate().advance |(j0, nj)| {
for data.slice(i, data.len()).iter().enumerate().advance |(j0, nj)| {
let j = j0 + i;
if i == j {
assert_eq!(ni.cmp(nj), Equal);
Expand Down Expand Up @@ -1654,7 +1653,7 @@ mod bigint_tests {
nums.push_all_move(vs.map(|s| BigInt::from_slice(Plus, *s)));

for nums.iter().enumerate().advance |(i, ni)| {
for vec::slice(nums, i, nums.len()).iter().enumerate().advance |(j0, nj)| {
for nums.slice(i, nums.len()).iter().enumerate().advance |(j0, nj)| {
let j = i + j0;
if i == j {
assert_eq!(ni.cmp(nj), Equal);
Expand Down
6 changes: 3 additions & 3 deletions src/libextra/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ impl<T:Ord> PriorityQueue<T> {
}

/// Returns the number of elements the queue can hold without reallocating
pub fn capacity(&self) -> uint { vec::capacity(&self.data) }
pub fn capacity(&self) -> uint { self.data.capacity() }

pub fn reserve(&mut self, n: uint) { vec::reserve(&mut self.data, n) }
pub fn reserve(&mut self, n: uint) { self.data.reserve(n) }

pub fn reserve_at_least(&mut self, n: uint) {
vec::reserve_at_least(&mut self.data, n)
self.data.reserve_at_least(n)
}

/// Pop the greatest item from the queue - fails if empty
Expand Down
Loading