提交 0cfdc99c 编写于 作者: J Jorge Aparicio

libcore: use unboxed closures in the fields of `SkipWhile`

上级 ca001e1b
......@@ -264,7 +264,7 @@ fn peekable(self) -> Peekable<A, Self> {
/// ```
#[inline]
#[unstable = "waiting for unboxed closures"]
fn skip_while<'r>(self, predicate: |&A|: 'r -> bool) -> SkipWhile<'r, A, Self> {
fn skip_while<P>(self, predicate: P) -> SkipWhile<A, Self, P> where P: FnMut(&A) -> bool {
SkipWhile{iter: self, flag: false, predicate: predicate}
}
......@@ -1645,14 +1645,14 @@ pub fn is_empty(&mut self) -> bool {
/// An iterator which rejects elements while `predicate` is true
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[stable]
pub struct SkipWhile<'a, A, T> {
iter: T,
pub struct SkipWhile<A, I, P> where I: Iterator<A>, P: FnMut(&A) -> bool {
iter: I,
flag: bool,
predicate: |&A|: 'a -> bool
predicate: P,
}
#[unstable = "trait is unstable"]
impl<'a, A, T: Iterator<A>> Iterator<A> for SkipWhile<'a, A, T> {
impl<A, I, P> Iterator<A> for SkipWhile<A, I, P> where I: Iterator<A>, P: FnMut(&A) -> bool {
#[inline]
fn next(&mut self) -> Option<A> {
for x in self.iter {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册