Skip to content

Commit fc9d717

Browse files
author
Jorge Aparicio
committed
---
yaml --- r: 164752 b: refs/heads/try c: 6ae9b9e h: refs/heads/master v: v3
1 parent bd7dd4e commit fc9d717

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: f8f2c7a9537c7f333b242f616aefb75a83860927
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 8443b09e361b96d1f9b7f45a65ed0d31c0e86e70
5-
refs/heads/try: 43cf7b4e457ad42aa44ad06469d6587ddb67eb2e
5+
refs/heads/try: 6ae9b9e54a9eb9711b32d663bb1a044f7540b4b0
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/libcore/slice.rs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -319,20 +319,23 @@ pub trait SlicePrelude<T> for Sized? {
319319
/// Returns an iterator over mutable subslices separated by elements that
320320
/// match `pred`. The matched element is not contained in the subslices.
321321
#[unstable = "waiting on unboxed closures, iterator type name conventions"]
322-
fn split_mut<'a>(&'a mut self, pred: |&T|: 'a -> bool) -> MutSplits<'a, T>;
322+
fn split_mut<'a, P>(&'a mut self, pred: P) -> MutSplits<'a, T, P> where
323+
P: FnMut(&T) -> bool;
323324

324325
/// Returns an iterator over subslices separated by elements that match
325326
/// `pred`, limited to splitting at most `n` times. The matched element is
326327
/// not contained in the subslices.
327328
#[unstable = "waiting on unboxed closures, iterator type name conventions"]
328-
fn splitn_mut<'a>(&'a mut self, n: uint, pred: |&T|: 'a -> bool) -> SplitsN<MutSplits<'a, T>>;
329+
fn splitn_mut<'a, P>(&'a mut self, n: uint, pred: P) -> SplitsN<MutSplits<'a, T, P>> where
330+
P: FnMut(&T) -> bool;
329331

330332
/// Returns an iterator over subslices separated by elements that match
331333
/// `pred` limited to splitting at most `n` times. This starts at the end of
332334
/// the slice and works backwards. The matched element is not contained in
333335
/// the subslices.
334336
#[unstable = "waiting on unboxed closures, iterator type name conventions"]
335-
fn rsplitn_mut<'a>(&'a mut self, n: uint, pred: |&T|: 'a -> bool) -> SplitsN<MutSplits<'a, T>>;
337+
fn rsplitn_mut<'a, P>(&'a mut self, n: uint, pred: P) -> SplitsN<MutSplits<'a, T, P>> where
338+
P: FnMut(&T) -> bool;
336339

337340
/// Returns an iterator over `chunk_size` elements of the slice at a time.
338341
/// The chunks are mutable and do not overlap. If `chunk_size` does
@@ -644,12 +647,14 @@ impl<T> SlicePrelude<T> for [T] {
644647
}
645648

646649
#[inline]
647-
fn split_mut<'a>(&'a mut self, pred: |&T|: 'a -> bool) -> MutSplits<'a, T> {
650+
fn split_mut<'a, P>(&'a mut self, pred: P) -> MutSplits<'a, T, P> where P: FnMut(&T) -> bool {
648651
MutSplits { v: self, pred: pred, finished: false }
649652
}
650653

651654
#[inline]
652-
fn splitn_mut<'a>(&'a mut self, n: uint, pred: |&T|: 'a -> bool) -> SplitsN<MutSplits<'a, T>> {
655+
fn splitn_mut<'a, P>(&'a mut self, n: uint, pred: P) -> SplitsN<MutSplits<'a, T, P>> where
656+
P: FnMut(&T) -> bool
657+
{
653658
SplitsN {
654659
iter: self.split_mut(pred),
655660
count: n,
@@ -658,7 +663,9 @@ impl<T> SlicePrelude<T> for [T] {
658663
}
659664

660665
#[inline]
661-
fn rsplitn_mut<'a>(&'a mut self, n: uint, pred: |&T|: 'a -> bool) -> SplitsN<MutSplits<'a, T>> {
666+
fn rsplitn_mut<'a, P>(&'a mut self, n: uint, pred: P) -> SplitsN<MutSplits<'a, T, P>> where
667+
P: FnMut(&T) -> bool,
668+
{
662669
SplitsN {
663670
iter: self.split_mut(pred),
664671
count: n,
@@ -1337,13 +1344,13 @@ impl<'a, T, P> SplitsIter<&'a [T]> for Splits<'a, T, P> where P: FnMut(&T) -> bo
13371344
/// An iterator over the subslices of the vector which are separated
13381345
/// by elements that match `pred`.
13391346
#[experimental = "needs review"]
1340-
pub struct MutSplits<'a, T:'a> {
1347+
pub struct MutSplits<'a, T:'a, P> where P: FnMut(&T) -> bool {
13411348
v: &'a mut [T],
1342-
pred: |t: &T|: 'a -> bool,
1349+
pred: P,
13431350
finished: bool
13441351
}
13451352

1346-
impl<'a, T> SplitsIter<&'a mut [T]> for MutSplits<'a, T> {
1353+
impl<'a, T, P> SplitsIter<&'a mut [T]> for MutSplits<'a, T, P> where P: FnMut(&T) -> bool {
13471354
#[inline]
13481355
fn finish(&mut self) -> Option<&'a mut [T]> {
13491356
if self.finished {
@@ -1356,7 +1363,7 @@ impl<'a, T> SplitsIter<&'a mut [T]> for MutSplits<'a, T> {
13561363
}
13571364

13581365
#[experimental = "needs review"]
1359-
impl<'a, T> Iterator<&'a mut [T]> for MutSplits<'a, T> {
1366+
impl<'a, T, P> Iterator<&'a mut [T]> for MutSplits<'a, T, P> where P: FnMut(&T) -> bool {
13601367
#[inline]
13611368
fn next(&mut self) -> Option<&'a mut [T]> {
13621369
if self.finished { return None; }
@@ -1389,7 +1396,9 @@ impl<'a, T> Iterator<&'a mut [T]> for MutSplits<'a, T> {
13891396
}
13901397

13911398
#[experimental = "needs review"]
1392-
impl<'a, T> DoubleEndedIterator<&'a mut [T]> for MutSplits<'a, T> {
1399+
impl<'a, T, P> DoubleEndedIterator<&'a mut [T]> for MutSplits<'a, T, P> where
1400+
P: FnMut(&T) -> bool,
1401+
{
13931402
#[inline]
13941403
fn next_back(&mut self) -> Option<&'a mut [T]> {
13951404
if self.finished { return None; }

0 commit comments

Comments
 (0)