From: Florian Ragwitz Date: Thu, 1 Apr 2010 04:13:44 +0000 (+0200) Subject: Stop Array::natatime from returning an exhausted iterator when being called with... X-Git-Tag: 1.02~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ee568bbf99f1ae86c64a2ce0c1d421ac2d2a97ac;p=gitmo%2FMoose.git Stop Array::natatime from returning an exhausted iterator when being called with a callback. --- diff --git a/Changes b/Changes index b15072a..baf1bb0 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,9 @@ for, noteworthy changes. [BUG FIXES] + * Stop the natatime method provided by the native Array trait from returning + an exhausted iterator when being called with a callback. (Florian Ragwitz) + * Make Moose::Meta::TypeConstraint::Class correctly reject RegexpRefs. (Florian Ragwitz) diff --git a/lib/Moose/Meta/Attribute/Native/MethodProvider/Array.pm b/lib/Moose/Meta/Attribute/Native/MethodProvider/Array.pm index a461749..0ccf12e 100644 --- a/lib/Moose/Meta/Attribute/Native/MethodProvider/Array.pm +++ b/lib/Moose/Meta/Attribute/Native/MethodProvider/Array.pm @@ -346,12 +346,13 @@ sub natatime : method { return sub { my ( $instance, $n, $f ) = @_; my $it = List::MoreUtils::natatime($n, @{ $reader->($instance) }); - if ($f) { - while (my @vals = $it->()) { - $f->(@vals); - } + return $it unless $f; + + while (my @vals = $it->()) { + $f->(@vals); } - $it; + + return; }; }