Skip to content

Commit f04f2dc

Browse files
committed
Add signature for Enumerator::Lazy#eager
1 parent 824f68e commit f04f2dc

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

core/enumerator.rbs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,14 @@ class Enumerator::Lazy[out Elem, out Return = void] < Enumerator[Elem, Return]
578578
# Like Enumerable#compact, but chains operation to be lazy-evaluated.
579579
#
580580
def compact: () -> Enumerator::Lazy[Elem, Return]
581+
582+
# <!--
583+
# rdoc-file=enumerator.c
584+
# - lzy.eager -> enum
585+
# -->
586+
# Returns a non-lazy Enumerator converted from the lazy enumerator.
587+
#
588+
def eager: () -> ::Enumerator[Elem, Return]
581589
end
582590

583591
# <!-- rdoc-file=enumerator.c -->

test/stdlib/Enumerator_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ def test_to_proc
8989
end
9090
end
9191

92+
class EnumeratorLazyInstanceTest < Test::Unit::TestCase
93+
include TestHelper
94+
95+
testing "::Enumerator::Lazy[::Integer, ::Range[Integer]]"
96+
97+
def test_eager
98+
assert_send_type "() -> Enumerator[Integer, Range[Integer]]", (1..3).lazy, :eager
99+
end
100+
end
101+
92102
class EnumeratorChainInstanceTest < Test::Unit::TestCase
93103
include TestHelper
94104

0 commit comments

Comments
 (0)