Skip to content

Commit 4f5b692

Browse files
committed
std: Rename various slice traits for consistency
ImmutableVector -> ImmutableSlice ImmutableEqVector -> ImmutableEqSlice ImmutableOrdVector -> ImmutableOrdSlice MutableVector -> MutableSlice MutableVectorAllocating -> MutableSliceAllocating MutableCloneableVector -> MutableCloneableSlice MutableOrdVector -> MutableOrdSlice These are all in the prelude so most code will not break. [breaking-change]
1 parent d917770 commit 4f5b692

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+80
-80
lines changed

src/libcollections/hash/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ mod tests {
296296
use std::prelude::*;
297297
use std::mem;
298298

299-
use slice::ImmutableVector;
299+
use slice::ImmutableSlice;
300300
use super::{Hash, Hasher, Writer};
301301

302302
struct MyWriterHasher;

src/libcollections/hash/sip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ mod tests {
275275

276276
use str::Str;
277277
use string::String;
278-
use slice::{Vector, ImmutableVector};
278+
use slice::{Vector, ImmutableSlice};
279279
use vec::Vec;
280280

281281
use super::super::{Hash, Writer};

src/libcollections/slice.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ represents iteration over a slice.
4545
## Traits
4646
4747
A number of traits add methods that allow you to accomplish tasks with slices.
48-
These traits include `ImmutableVector`, which is defined for `&[T]` types,
49-
and `MutableVector`, defined for `&mut [T]` types.
48+
These traits include `ImmutableSlice`, which is defined for `&[T]` types,
49+
and `MutableSlice`, defined for `&mut [T]` types.
5050
5151
An example is the method `.slice(a, b)` that returns an immutable "view" into
5252
a `Vec` or another slice from the index interval `[a, b)`:
@@ -98,10 +98,10 @@ use {Collection, MutableSeq};
9898
use vec::Vec;
9999

100100
pub use core::slice::{ref_slice, mut_ref_slice, Splits, Windows};
101-
pub use core::slice::{Chunks, Vector, ImmutableVector, ImmutableEqVector};
102-
pub use core::slice::{ImmutableOrdVector, MutableVector, Items, MutItems};
101+
pub use core::slice::{Chunks, Vector, ImmutableSlice, ImmutableEqSlice};
102+
pub use core::slice::{ImmutableOrdSlice, MutableSlice, Items, MutItems};
103103
pub use core::slice::{MutSplits, MutChunks};
104-
pub use core::slice::{bytes, MutableCloneableVector};
104+
pub use core::slice::{bytes, MutableCloneableSlice};
105105

106106
// Functional utilities
107107

@@ -558,7 +558,7 @@ fn merge_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
558558

559559
/// Extension methods for vectors such that their elements are
560560
/// mutable.
561-
pub trait MutableVectorAllocating<'a, T> {
561+
pub trait MutableSliceAllocating<'a, T> {
562562
/// Sort the vector, in place, using `compare` to compare
563563
/// elements.
564564
///
@@ -604,7 +604,7 @@ pub trait MutableVectorAllocating<'a, T> {
604604
fn move_from(self, src: Vec<T>, start: uint, end: uint) -> uint;
605605
}
606606

607-
impl<'a,T> MutableVectorAllocating<'a, T> for &'a mut [T] {
607+
impl<'a,T> MutableSliceAllocating<'a, T> for &'a mut [T] {
608608
#[inline]
609609
fn sort_by(self, compare: |&T, &T| -> Ordering) {
610610
merge_sort(self, compare)
@@ -621,7 +621,7 @@ impl<'a,T> MutableVectorAllocating<'a, T> for &'a mut [T] {
621621

622622
/// Methods for mutable vectors with orderable elements, such as
623623
/// in-place sorting.
624-
pub trait MutableOrdVector<T> {
624+
pub trait MutableOrdSlice<T> {
625625
/// Sort the vector, in place.
626626
///
627627
/// This is equivalent to `self.sort_by(|a, b| a.cmp(b))`.
@@ -667,7 +667,7 @@ pub trait MutableOrdVector<T> {
667667
fn prev_permutation(self) -> bool;
668668
}
669669

670-
impl<'a, T: Ord> MutableOrdVector<T> for &'a mut [T] {
670+
impl<'a, T: Ord> MutableOrdSlice<T> for &'a mut [T] {
671671
#[inline]
672672
fn sort(self) {
673673
self.sort_by(|a,b| a.cmp(b))

src/libcollections/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ mod tests {
894894
use {Collection, MutableSeq};
895895

896896
use super::*;
897-
use std::slice::{Vector, ImmutableVector};
897+
use std::slice::{Vector, ImmutableSlice};
898898
use string::String;
899899
use vec::Vec;
900900

src/libcollections/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use core::ptr;
2424
use core::uint;
2525

2626
use {Collection, Mutable, MutableSeq};
27-
use slice::{MutableOrdVector, MutableVectorAllocating, CloneableVector};
27+
use slice::{MutableOrdSlice, MutableSliceAllocating, CloneableVector};
2828
use slice::{Items, MutItems};
2929

3030

src/libcore/fmt/float.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use iter::{range, DoubleEndedIterator};
1717
use num::{Float, FPNaN, FPInfinite, ToPrimitive, Primitive};
1818
use num::{Zero, One, cast};
1919
use result::Ok;
20-
use slice::{ImmutableVector, MutableVector};
20+
use slice::{ImmutableSlice, MutableSlice};
2121
use slice;
2222
use str::StrSlice;
2323

src/libcore/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use option::{Option, Some, None};
2424
use ops::Deref;
2525
use result::{Ok, Err};
2626
use result;
27-
use slice::{Vector, ImmutableVector};
27+
use slice::{Vector, ImmutableSlice};
2828
use slice;
2929
use str::StrSlice;
3030
use str;

src/libcore/fmt/num.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use collections::Collection;
1818
use fmt;
1919
use iter::DoubleEndedIterator;
2020
use num::{Int, cast, zero};
21-
use slice::{ImmutableVector, MutableVector};
21+
use slice::{ImmutableSlice, MutableSlice};
2222

2323
/// A type that represents a specific radix
2424
#[doc(hidden)]

src/libcore/prelude.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ pub use str::{Str, StrSlice};
6161
pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
6262
pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
6363
pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
64-
pub use slice::{ImmutableEqVector, ImmutableOrdVector};
65-
pub use slice::{MutableVector};
66-
pub use slice::{Vector, ImmutableVector};
64+
pub use slice::{ImmutableEqSlice, ImmutableOrdSlice};
65+
pub use slice::{MutableSlice};
66+
pub use slice::{Vector, ImmutableSlice};

src/libcore/slice.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ use raw::{Repr, Slice};
5454
//
5555

5656
/// Extension methods for vectors
57-
pub trait ImmutableVector<'a, T> {
57+
pub trait ImmutableSlice<'a, T> {
5858
/**
5959
* Returns a slice of self spanning the interval [`start`, `end`).
6060
*
@@ -234,7 +234,7 @@ pub trait ImmutableVector<'a, T> {
234234
fn pop_ref(&mut self) -> Option<&'a T>;
235235
}
236236

237-
impl<'a,T> ImmutableVector<'a, T> for &'a [T] {
237+
impl<'a,T> ImmutableSlice<'a, T> for &'a [T] {
238238
#[inline]
239239
fn slice(&self, start: uint, end: uint) -> &'a [T] {
240240
assert!(start <= end);
@@ -401,7 +401,7 @@ impl<'a,T> ImmutableVector<'a, T> for &'a [T] {
401401

402402
/// Extension methods for vectors such that their elements are
403403
/// mutable.
404-
pub trait MutableVector<'a, T> {
404+
pub trait MutableSlice<'a, T> {
405405
/// Returns a mutable reference to the element at the given index,
406406
/// or `None` if the index is out of bounds
407407
fn get_mut(self, index: uint) -> Option<&'a mut T>;
@@ -607,7 +607,7 @@ pub trait MutableVector<'a, T> {
607607
unsafe fn copy_memory(self, src: &[T]);
608608
}
609609

610-
impl<'a,T> MutableVector<'a, T> for &'a mut [T] {
610+
impl<'a,T> MutableSlice<'a, T> for &'a mut [T] {
611611
#[inline]
612612
fn get_mut(self, index: uint) -> Option<&'a mut T> {
613613
if index < self.len() { Some(&mut self[index]) } else { None }
@@ -755,7 +755,7 @@ impl<'a,T> MutableVector<'a, T> for &'a mut [T] {
755755
}
756756

757757
/// Extension methods for vectors contain `PartialEq` elements.
758-
pub trait ImmutableEqVector<T:PartialEq> {
758+
pub trait ImmutableEqSlice<T:PartialEq> {
759759
/// Find the first index containing a matching value
760760
fn position_elem(&self, t: &T) -> Option<uint>;
761761

@@ -772,7 +772,7 @@ pub trait ImmutableEqVector<T:PartialEq> {
772772
fn ends_with(&self, needle: &[T]) -> bool;
773773
}
774774

775-
impl<'a,T:PartialEq> ImmutableEqVector<T> for &'a [T] {
775+
impl<'a,T:PartialEq> ImmutableEqSlice<T> for &'a [T] {
776776
#[inline]
777777
fn position_elem(&self, x: &T) -> Option<uint> {
778778
self.iter().position(|y| *x == *y)
@@ -802,7 +802,7 @@ impl<'a,T:PartialEq> ImmutableEqVector<T> for &'a [T] {
802802
}
803803

804804
/// Extension methods for vectors containing `Ord` elements.
805-
pub trait ImmutableOrdVector<T: Ord> {
805+
pub trait ImmutableOrdSlice<T: Ord> {
806806
/**
807807
* Binary search a sorted vector for a given element.
808808
*
@@ -811,22 +811,22 @@ pub trait ImmutableOrdVector<T: Ord> {
811811
fn bsearch_elem(&self, x: &T) -> Option<uint>;
812812
}
813813

814-
impl<'a, T: Ord> ImmutableOrdVector<T> for &'a [T] {
814+
impl<'a, T: Ord> ImmutableOrdSlice<T> for &'a [T] {
815815
fn bsearch_elem(&self, x: &T) -> Option<uint> {
816816
self.bsearch(|p| p.cmp(x))
817817
}
818818
}
819819

820820
/// Trait for &[T] where T is Cloneable
821-
pub trait MutableCloneableVector<T> {
821+
pub trait MutableCloneableSlice<T> {
822822
/// Copies as many elements from `src` as it can into `self` (the
823823
/// shorter of `self.len()` and `src.len()`). Returns the number
824824
/// of elements copied.
825825
///
826826
/// # Example
827827
///
828828
/// ```rust
829-
/// use std::slice::MutableCloneableVector;
829+
/// use std::slice::MutableCloneableSlice;
830830
///
831831
/// let mut dst = [0i, 0, 0];
832832
/// let src = [1i, 2];
@@ -841,7 +841,7 @@ pub trait MutableCloneableVector<T> {
841841
fn copy_from(self, &[T]) -> uint;
842842
}
843843

844-
impl<'a, T:Clone> MutableCloneableVector<T> for &'a mut [T] {
844+
impl<'a, T:Clone> MutableCloneableSlice<T> for &'a mut [T] {
845845
#[inline]
846846
fn copy_from(self, src: &[T]) -> uint {
847847
for (a, b) in self.mut_iter().zip(src.iter()) {
@@ -1413,7 +1413,7 @@ pub mod raw {
14131413
pub mod bytes {
14141414
use collections::Collection;
14151415
use ptr;
1416-
use slice::MutableVector;
1416+
use slice::MutableSlice;
14171417

14181418
/// A trait for operations on mutable `[u8]`s.
14191419
pub trait MutableByteVector {

src/libcore/str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use iter::range;
3030
use num::{CheckedMul, Saturating};
3131
use option::{Option, None, Some};
3232
use raw::Repr;
33-
use slice::ImmutableVector;
33+
use slice::ImmutableSlice;
3434
use slice;
3535
use uint;
3636

@@ -964,7 +964,7 @@ pub mod raw {
964964
use collections::Collection;
965965
use ptr::RawPtr;
966966
use raw::Slice;
967-
use slice::{ImmutableVector};
967+
use slice::{ImmutableSlice};
968968
use str::{is_utf8, StrSlice};
969969

970970
/// Converts a slice of bytes to a string slice without checking

src/libregex/vm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
use std::cmp;
3737
use std::mem;
38-
use std::slice::MutableVector;
38+
use std::slice::MutableSlice;
3939
use compile::{
4040
Program,
4141
Match, OneChar, CharClass, Any, EmptyBegin, EmptyEnd, EmptyWordBoundary,

src/librlibc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ mod test {
112112
use core::iter::Iterator;
113113
use core::collections::Collection;
114114
use core::str::StrSlice;
115-
use core::slice::{MutableVector, ImmutableVector};
115+
use core::slice::{MutableSlice, ImmutableSlice};
116116

117117
use super::{memcmp, memset, memcpy, memmove};
118118

src/libstd/ascii.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use fmt;
1919
use iter::Iterator;
2020
use mem;
2121
use option::{Option, Some, None};
22-
use slice::{ImmutableVector, MutableVector, Vector};
22+
use slice::{ImmutableSlice, MutableSlice, Vector};
2323
use str::{Str, StrSlice};
2424
use str;
2525
use string::String;

src/libstd/collections/hashmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2743,7 +2743,7 @@ mod test_set {
27432743
use prelude::*;
27442744

27452745
use super::HashSet;
2746-
use slice::ImmutableEqVector;
2746+
use slice::ImmutableEqSlice;
27472747
use collections::Collection;
27482748

27492749
#[test]

src/libstd/dynamic_lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use option::*;
2929
use os;
3030
use path::{Path,GenericPath};
3131
use result::*;
32-
use slice::{Vector,ImmutableVector};
32+
use slice::{Vector,ImmutableSlice};
3333
use str;
3434
use string::String;
3535
use vec::Vec;

src/libstd/io/buffered.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use iter::ExactSize;
1919
use ops::Drop;
2020
use option::{Some, None, Option};
2121
use result::{Ok, Err};
22-
use slice::{ImmutableVector, MutableVector};
22+
use slice::{ImmutableSlice, MutableSlice};
2323
use slice;
2424
use vec::Vec;
2525

src/libstd/io/comm_adapters.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use comm::{Sender, Receiver};
1515
use io;
1616
use option::{None, Option, Some};
1717
use result::{Ok, Err};
18-
use slice::{bytes, MutableVector, ImmutableVector};
18+
use slice::{bytes, MutableSlice, ImmutableSlice};
1919
use str::StrSlice;
2020
use super::{Reader, Writer, IoResult};
2121
use vec::Vec;

src/libstd/io/extensions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use option::{Option, Some, None};
2121
use result::{Ok, Err};
2222
use io;
2323
use io::{IoError, IoResult, Reader};
24-
use slice::{ImmutableVector, Vector};
24+
use slice::{ImmutableSlice, Vector};
2525
use ptr::RawPtr;
2626

2727
/// An iterator that reads a single byte on each iteration,
@@ -153,7 +153,7 @@ pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
153153
pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
154154
use ptr::{copy_nonoverlapping_memory};
155155
use mem::from_be64;
156-
use slice::MutableVector;
156+
use slice::MutableSlice;
157157

158158
assert!(size <= 8u);
159159

src/libstd/io/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ use path;
7070
use result::{Err, Ok};
7171
use rt::rtio::LocalIo;
7272
use rt::rtio;
73-
use slice::ImmutableVector;
73+
use slice::ImmutableSlice;
7474
use string::String;
7575
use vec::Vec;
7676

src/libstd/io/mem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use result::{Err, Ok};
1919
use io;
2020
use io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult};
2121
use slice;
22-
use slice::{Vector, ImmutableVector, MutableVector};
22+
use slice::{Vector, ImmutableSlice, MutableSlice};
2323
use vec::Vec;
2424

2525
static BUF_CAPACITY: uint = 128;

src/libstd/io/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ use os;
235235
use boxed::Box;
236236
use result::{Ok, Err, Result};
237237
use rt::rtio;
238-
use slice::{Vector, MutableVector, ImmutableVector};
238+
use slice::{Vector, MutableSlice, ImmutableSlice};
239239
use str::{Str, StrSlice};
240240
use str;
241241
use string::String;

src/libstd/io/net/ip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use from_str::FromStr;
2121
use iter::Iterator;
2222
use option::{Option, None, Some};
2323
use str::StrSlice;
24-
use slice::{MutableCloneableVector, ImmutableVector, MutableVector};
24+
use slice::{MutableCloneableSlice, ImmutableSlice, MutableSlice};
2525

2626
pub type Port = u16;
2727

src/libstd/io/net/tcp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use clone::Clone;
2121
use collections::MutableSeq;
2222
use io::IoResult;
2323
use iter::Iterator;
24-
use slice::ImmutableVector;
24+
use slice::ImmutableSlice;
2525
use result::{Ok,Err};
2626
use io::net::addrinfo::get_host_addresses;
2727
use io::net::ip::SocketAddr;

src/libstd/io/signal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use option::{Some, None};
3030
use boxed::Box;
3131
use result::{Ok, Err};
3232
use rt::rtio::{IoFactory, LocalIo, RtioSignal, Callback};
33-
use slice::ImmutableVector;
33+
use slice::ImmutableSlice;
3434
use vec::Vec;
3535

3636
/// Signals that can be sent and received

0 commit comments

Comments
 (0)