Skip to content

Commit c0c6c89

Browse files
committed
Revert "Remove the _ suffix from slice methods."
This reverts commit df2f1fa.
1 parent 7bf56df commit c0c6c89

File tree

7 files changed

+97
-188
lines changed

7 files changed

+97
-188
lines changed

src/libcollections/trie.rs

-18
Original file line numberDiff line numberDiff line change
@@ -389,22 +389,13 @@ macro_rules! bound {
389389

390390
impl<T> TrieMap<T> {
391391
// If `upper` is true then returns upper_bound else returns lower_bound.
392-
#[cfg(stage0)]
393392
#[inline]
394393
fn bound<'a>(&'a self, key: uint, upper: bool) -> Entries<'a, T> {
395394
bound!(Entries, self = self,
396395
key = key, is_upper = upper,
397396
slice_from = slice_from_, iter = iter,
398397
mutability = )
399398
}
400-
#[cfg(not(stage0))]
401-
#[inline]
402-
fn bound<'a>(&'a self, key: uint, upper: bool) -> Entries<'a, T> {
403-
bound!(Entries, self = self,
404-
key = key, is_upper = upper,
405-
slice_from = slice_from, iter = iter,
406-
mutability = )
407-
}
408399

409400
/// Gets an iterator pointing to the first key-value pair whose key is not less than `key`.
410401
/// If all keys in the map are less than `key` an empty iterator is returned.
@@ -440,22 +431,13 @@ impl<T> TrieMap<T> {
440431
self.bound(key, true)
441432
}
442433
// If `upper` is true then returns upper_bound else returns lower_bound.
443-
#[cfg(stage0)]
444434
#[inline]
445435
fn bound_mut<'a>(&'a mut self, key: uint, upper: bool) -> MutEntries<'a, T> {
446436
bound!(MutEntries, self = self,
447437
key = key, is_upper = upper,
448438
slice_from = slice_from_mut_, iter = iter_mut,
449439
mutability = mut)
450440
}
451-
#[cfg(not(stage0))]
452-
#[inline]
453-
fn bound_mut<'a>(&'a mut self, key: uint, upper: bool) -> MutEntries<'a, T> {
454-
bound!(MutEntries, self = self,
455-
key = key, is_upper = upper,
456-
slice_from = slice_from_mut, iter = iter_mut,
457-
mutability = mut)
458-
}
459441

460442
/// Deprecated: use `lower_bound_mut`.
461443
#[deprecated = "use lower_bound_mut"]

src/libcollections/vec.rs

-53
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use core::num;
2424
use core::ops;
2525
use core::ptr;
2626
use core::raw::Slice as RawSlice;
27-
use core::slice::Slice as SliceSlice;
2827
use core::uint;
2928

3029
use {Mutable, MutableSeq};
@@ -461,36 +460,6 @@ impl<T> Index<uint,T> for Vec<T> {
461460
}
462461
}*/
463462

464-
// Annoying helper function because there are two Slice::as_slice functions in
465-
// scope.
466-
#[inline]
467-
fn slice_to_slice<'a, T, U: Slice<T>>(this: &'a U) -> &'a [T] {
468-
this.as_slice()
469-
}
470-
471-
472-
#[cfg(not(stage0))]
473-
impl<T> ops::Slice<uint, [T]> for Vec<T> {
474-
#[inline]
475-
fn as_slice<'a>(&'a self) -> &'a [T] {
476-
slice_to_slice(self)
477-
}
478-
479-
#[inline]
480-
fn slice_from<'a>(&'a self, start: &uint) -> &'a [T] {
481-
slice_to_slice(self).slice_from(start)
482-
}
483-
484-
#[inline]
485-
fn slice_to<'a>(&'a self, end: &uint) -> &'a [T] {
486-
slice_to_slice(self).slice_to(end)
487-
}
488-
#[inline]
489-
fn slice<'a>(&'a self, start: &uint, end: &uint) -> &'a [T] {
490-
slice_to_slice(self).slice(start, end)
491-
}
492-
}
493-
#[cfg(stage0)]
494463
impl<T> ops::Slice<uint, [T]> for Vec<T> {
495464
#[inline]
496465
fn as_slice_<'a>(&'a self) -> &'a [T] {
@@ -512,28 +481,6 @@ impl<T> ops::Slice<uint, [T]> for Vec<T> {
512481
}
513482
}
514483

515-
#[cfg(not(stage0))]
516-
impl<T> ops::SliceMut<uint, [T]> for Vec<T> {
517-
#[inline]
518-
fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
519-
self.as_mut_slice()
520-
}
521-
522-
#[inline]
523-
fn slice_from_mut<'a>(&'a mut self, start: &uint) -> &'a mut [T] {
524-
self.as_mut_slice().slice_from_mut(start)
525-
}
526-
527-
#[inline]
528-
fn slice_to_mut<'a>(&'a mut self, end: &uint) -> &'a mut [T] {
529-
self.as_mut_slice().slice_to_mut(end)
530-
}
531-
#[inline]
532-
fn slice_mut<'a>(&'a mut self, start: &uint, end: &uint) -> &'a mut [T] {
533-
self.as_mut_slice().slice_mut(start, end)
534-
}
535-
}
536-
#[cfg(stage0)]
537484
impl<T> ops::SliceMut<uint, [T]> for Vec<T> {
538485
#[inline]
539486
fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {

src/libcore/ops.rs

+10-41
Original file line numberDiff line numberDiff line change
@@ -688,19 +688,19 @@ pub trait IndexMut<Index, Result> {
688688
* struct Foo;
689689
*
690690
* impl ::core::ops::Slice<Foo, Foo> for Foo {
691-
* fn as_slice<'a>(&'a self) -> &'a Foo {
691+
* fn as_slice_<'a>(&'a self) -> &'a Foo {
692692
* println!("Slicing!");
693693
* self
694694
* }
695-
* fn slice_from<'a>(&'a self, from: &Foo) -> &'a Foo {
695+
* fn slice_from_<'a>(&'a self, from: &Foo) -> &'a Foo {
696696
* println!("Slicing!");
697697
* self
698698
* }
699-
* fn slice_to<'a>(&'a self, to: &Foo) -> &'a Foo {
699+
* fn slice_to_<'a>(&'a self, to: &Foo) -> &'a Foo {
700700
* println!("Slicing!");
701701
* self
702702
* }
703-
* fn slice<'a>(&'a self, from: &Foo, to: &Foo) -> &'a Foo {
703+
* fn slice_<'a>(&'a self, from: &Foo, to: &Foo) -> &'a Foo {
704704
* println!("Slicing!");
705705
* self
706706
* }
@@ -711,22 +711,7 @@ pub trait IndexMut<Index, Result> {
711711
* }
712712
* ```
713713
*/
714-
#[cfg(not(stage0))]
715-
#[lang="slice"]
716-
pub trait Slice<Idx, Sized? Result> for Sized? {
717-
/// The method for the slicing operation foo[]
718-
fn as_slice<'a>(&'a self) -> &'a Result;
719-
/// The method for the slicing operation foo[from..]
720-
fn slice_from<'a>(&'a self, from: &Idx) -> &'a Result;
721-
/// The method for the slicing operation foo[..to]
722-
fn slice_to<'a>(&'a self, to: &Idx) -> &'a Result;
723-
/// The method for the slicing operation foo[from..to]
724-
fn slice<'a>(&'a self, from: &Idx, to: &Idx) -> &'a Result;
725-
}
726-
/**
727-
*
728-
*/
729-
#[cfg(stage0)]
714+
// FIXME(#17273) remove the postscript _s
730715
#[lang="slice"]
731716
pub trait Slice<Idx, Sized? Result> for Sized? {
732717
/// The method for the slicing operation foo[]
@@ -753,19 +738,19 @@ pub trait Slice<Idx, Sized? Result> for Sized? {
753738
* struct Foo;
754739
*
755740
* impl ::core::ops::SliceMut<Foo, Foo> for Foo {
756-
* fn as_mut_slice<'a>(&'a mut self) -> &'a mut Foo {
741+
* fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Foo {
757742
* println!("Slicing!");
758743
* self
759744
* }
760-
* fn slice_from_mut<'a>(&'a mut self, from: &Foo) -> &'a mut Foo {
745+
* fn slice_from_mut_<'a>(&'a mut self, from: &Foo) -> &'a mut Foo {
761746
* println!("Slicing!");
762747
* self
763748
* }
764-
* fn slice_to_mut<'a>(&'a mut self, to: &Foo) -> &'a mut Foo {
749+
* fn slice_to_mut_<'a>(&'a mut self, to: &Foo) -> &'a mut Foo {
765750
* println!("Slicing!");
766751
* self
767752
* }
768-
* fn slice_mut<'a>(&'a mut self, from: &Foo, to: &Foo) -> &'a mut Foo {
753+
* fn slice_mut_<'a>(&'a mut self, from: &Foo, to: &Foo) -> &'a mut Foo {
769754
* println!("Slicing!");
770755
* self
771756
* }
@@ -776,22 +761,7 @@ pub trait Slice<Idx, Sized? Result> for Sized? {
776761
* }
777762
* ```
778763
*/
779-
#[cfg(not(stage0))]
780-
#[lang="slice_mut"]
781-
pub trait SliceMut<Idx, Sized? Result> for Sized? {
782-
/// The method for the slicing operation foo[]
783-
fn as_mut_slice<'a>(&'a mut self) -> &'a mut Result;
784-
/// The method for the slicing operation foo[from..]
785-
fn slice_from_mut<'a>(&'a mut self, from: &Idx) -> &'a mut Result;
786-
/// The method for the slicing operation foo[..to]
787-
fn slice_to_mut<'a>(&'a mut self, to: &Idx) -> &'a mut Result;
788-
/// The method for the slicing operation foo[from..to]
789-
fn slice_mut<'a>(&'a mut self, from: &Idx, to: &Idx) -> &'a mut Result;
790-
}
791-
/**
792-
*
793-
*/
794-
#[cfg(stage0)]
764+
// FIXME(#17273) remove the postscript _s
795765
#[lang="slice_mut"]
796766
pub trait SliceMut<Idx, Sized? Result> for Sized? {
797767
/// The method for the slicing operation foo[mut]
@@ -803,7 +773,6 @@ pub trait SliceMut<Idx, Sized? Result> for Sized? {
803773
/// The method for the slicing operation foo[mut from..to]
804774
fn slice_mut_<'a>(&'a mut self, from: &Idx, to: &Idx) -> &'a mut Result;
805775
}
806-
807776
/**
808777
*
809778
* The `Deref` trait is used to specify the functionality of dereferencing

src/libcore/slice.rs

+69-58
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,32 @@ use raw::Slice as RawSlice;
6161
/// Extension methods for immutable slices.
6262
#[unstable = "may merge with other traits; region parameter may disappear"]
6363
pub trait ImmutableSlice<'a, T> {
64+
/// Returns a subslice spanning the interval [`start`, `end`).
65+
///
66+
/// Fails when the end of the new slice lies beyond the end of the
67+
/// original slice (i.e. when `end > self.len()`) or when `start > end`.
68+
///
69+
/// Slicing with `start` equal to `end` yields an empty slice.
70+
#[unstable = "waiting on final error conventions"]
71+
//fn slice(&self, start: uint, end: uint) -> &'a [T];
72+
73+
/// Returns a subslice from `start` to the end of the slice.
74+
///
75+
/// Fails when `start` is strictly greater than the length of the original slice.
76+
///
77+
/// Slicing from `self.len()` yields an empty slice.
78+
#[unstable = "waiting on final error conventions"]
79+
// TODO
80+
//fn slice_from(&self, start: uint) -> &'a [T];
81+
82+
/// Returns a subslice from the start of the slice to `end`.
83+
///
84+
/// Fails when `end` is strictly greater than the length of the original slice.
85+
///
86+
/// Slicing to `0` yields an empty slice.
87+
#[unstable = "waiting on final error conventions"]
88+
//fn slice_to(&self, end: uint) -> &'a [T];
89+
6490
/// Divides one slice into two at an index.
6591
///
6692
/// The first will contain all indices from `[0, mid)` (excluding
@@ -418,35 +444,6 @@ impl<'a,T> ImmutableSlice<'a, T> for &'a [T] {
418444
}
419445
}
420446

421-
#[cfg(not(stage0))]
422-
impl<T> ops::Slice<uint, [T]> for [T] {
423-
#[inline]
424-
fn as_slice<'a>(&'a self) -> &'a [T] {
425-
self
426-
}
427-
428-
#[inline]
429-
fn slice_from<'a>(&'a self, start: &uint) -> &'a [T] {
430-
self.slice(start, &self.len())
431-
}
432-
433-
#[inline]
434-
fn slice_to<'a>(&'a self, end: &uint) -> &'a [T] {
435-
self.slice(&0, end)
436-
}
437-
#[inline]
438-
fn slice<'a>(&'a self, start: &uint, end: &uint) -> &'a [T] {
439-
assert!(*start <= *end);
440-
assert!(*end <= self.len());
441-
unsafe {
442-
transmute(RawSlice {
443-
data: self.as_ptr().offset(*start as int),
444-
len: (*end - *start)
445-
})
446-
}
447-
}
448-
}
449-
#[cfg(stage0)]
450447
impl<T> ops::Slice<uint, [T]> for [T] {
451448
#[inline]
452449
fn as_slice_<'a>(&'a self) -> &'a [T] {
@@ -474,36 +471,7 @@ impl<T> ops::Slice<uint, [T]> for [T] {
474471
}
475472
}
476473
}
477-
#[cfg(not(stage0))]
478-
impl<T> ops::SliceMut<uint, [T]> for [T] {
479-
#[inline]
480-
fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
481-
self
482-
}
483-
484-
#[inline]
485-
fn slice_from_mut<'a>(&'a mut self, start: &uint) -> &'a mut [T] {
486-
let len = &self.len();
487-
self.slice_mut(start, len)
488-
}
489474

490-
#[inline]
491-
fn slice_to_mut<'a>(&'a mut self, end: &uint) -> &'a mut [T] {
492-
self.slice_mut(&0, end)
493-
}
494-
#[inline]
495-
fn slice_mut<'a>(&'a mut self, start: &uint, end: &uint) -> &'a mut [T] {
496-
assert!(*start <= *end);
497-
assert!(*end <= self.len());
498-
unsafe {
499-
transmute(RawSlice {
500-
data: self.as_ptr().offset(*start as int),
501-
len: (*end - *start)
502-
})
503-
}
504-
}
505-
}
506-
#[cfg(stage0)]
507475
impl<T> ops::SliceMut<uint, [T]> for [T] {
508476
#[inline]
509477
fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {
@@ -546,6 +514,49 @@ pub trait MutableSlice<'a, T> {
546514
#[deprecated = "use slicing syntax"]
547515
fn as_mut_slice(self) -> &'a mut [T];
548516

517+
/// Deprecated: use `slice_mut`.
518+
#[deprecated = "use slicing syntax"]
519+
//fn mut_slice(self, start: uint, end: uint) -> &'a mut [T] {
520+
// self[mut start..end]
521+
//}
522+
523+
/// Returns a mutable subslice spanning the interval [`start`, `end`).
524+
///
525+
/// Fails when the end of the new slice lies beyond the end of the
526+
/// original slice (i.e. when `end > self.len()`) or when `start > end`.
527+
///
528+
/// Slicing with `start` equal to `end` yields an empty slice.
529+
#[unstable = "waiting on final error conventions"]
530+
//fn slice_mut(self, start: uint, end: uint) -> &'a mut [T];
531+
532+
/// Deprecated: use `slicing syntax`.
533+
#[deprecated = "use slicing syntax"]
534+
//fn mut_slice_from(self, start: uint) -> &'a mut [T] {
535+
// self[mut start..]
536+
//}
537+
538+
/// Returns a mutable subslice from `start` to the end of the slice.
539+
///
540+
/// Fails when `start` is strictly greater than the length of the original slice.
541+
///
542+
/// Slicing from `self.len()` yields an empty slice.
543+
#[unstable = "waiting on final error conventions"]
544+
//fn slice_from_mut(self, start: uint) -> &'a mut [T];
545+
546+
/// Deprecated: use `slicing syntax`.
547+
#[deprecated = "use slicing syntax"]
548+
//fn mut_slice_to(self, end: uint) -> &'a mut [T] {
549+
// self[mut ..end]
550+
//}
551+
552+
/// Returns a mutable subslice from the start of the slice to `end`.
553+
///
554+
/// Fails when `end` is strictly greater than the length of the original slice.
555+
///
556+
/// Slicing to `0` yields an empty slice.
557+
#[unstable = "waiting on final error conventions"]
558+
//fn slice_to_mut(self, end: uint) -> &'a mut [T];
559+
549560
/// Deprecated: use `iter_mut`.
550561
#[deprecated = "use iter_mut"]
551562
fn mut_iter(self) -> MutItems<'a, T> {

src/libcoretest/iter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ fn test_all() {
373373
assert!(v.iter().all(|&x| x < 10));
374374
assert!(!v.iter().all(|&x| x % 2 == 0));
375375
assert!(!v.iter().all(|&x| x > 100));
376-
assert!(v.slice(&0, &0).iter().all(|_| fail!()));
376+
assert!(v.slice_(&0, &0).iter().all(|_| fail!()));
377377
}
378378

379379
#[test]
@@ -382,7 +382,7 @@ fn test_any() {
382382
assert!(v.iter().any(|&x| x < 10));
383383
assert!(v.iter().any(|&x| x % 2 == 0));
384384
assert!(!v.iter().any(|&x| x > 100));
385-
assert!(!v.slice(&0, &0).iter().any(|_| fail!()));
385+
assert!(!v.slice_(&0, &0).iter().any(|_| fail!()));
386386
}
387387

388388
#[test]

0 commit comments

Comments
 (0)