Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
290 changes: 145 additions & 145 deletions core/array.rbs

Large diffs are not rendered by default.

222 changes: 111 additions & 111 deletions core/enumerable.rbs

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions core/enumerator.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@
# puts ext_each(o.to_enum) {|*x| puts x; [:b, *x] }
# # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3
#
class Enumerator[unchecked out Elem, out Return = void] < Object
include Enumerable[Elem]
class Enumerator[unchecked out E, out R = void] < Object
include Enumerable[E]

# A convenience interface for `each` with optional block
#
Expand Down Expand Up @@ -210,7 +210,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
# When a block is given, calls the block with each N-element array generated and
# returns `nil`.
#
def self.product: [Elem] (*_EachEntry[Elem]) -> Product[Elem]
def self.product: [E] (*_EachEntry[E]) -> Product[E]

# <!--
# rdoc-file=enumerator.c
Expand Down Expand Up @@ -247,7 +247,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
# enum.each(:y, :z).equal?(enum) #=> false
# enum.each(:y, :z) { |elm| elm } #=> :method_returned
#
def each: () { (Elem arg0) -> untyped } -> Return
def each: () { (E arg0) -> untyped } -> R
| () -> self

# <!--
Expand Down Expand Up @@ -295,7 +295,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
# e.next # (7)
# # (10)
#
def feed: (Elem arg0) -> NilClass
def feed: (E arg0) -> NilClass

# <!--
# rdoc-file=enumerator.c
Expand All @@ -321,7 +321,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
# lazy fashion (see Enumerator#size). It can either be a value or a callable
# object.
#
def initialize: (?Integer arg0) { (Enumerator::Yielder arg0) -> Return } -> void
def initialize: (?Integer arg0) { (Enumerator::Yielder arg0) -> R } -> void

# <!--
# rdoc-file=enumerator.c
Expand Down Expand Up @@ -349,7 +349,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
#
# See class-level notes about external iterators.
#
def next: () -> Elem
def next: () -> E

# <!--
# rdoc-file=enumerator.c
Expand Down Expand Up @@ -393,7 +393,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
# # yield nil [nil] nil
# # yield [1, 2] [[1, 2]] [1, 2]
#
def next_values: () -> ::Array[Elem]
def next_values: () -> ::Array[E]

# <!--
# rdoc-file=enumerator.c
Expand All @@ -417,7 +417,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
# p e.next #=> 3
# p e.peek #raises StopIteration
#
def peek: () -> Elem
def peek: () -> E

# <!--
# rdoc-file=enumerator.c
Expand Down Expand Up @@ -447,7 +447,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
# e.next
# p e.peek_values # raises StopIteration
#
def peek_values: () -> ::Array[Elem]
def peek_values: () -> ::Array[E]

# <!--
# rdoc-file=enumerator.c
Expand Down Expand Up @@ -500,7 +500,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
# e = (1..3).each + [4, 5]
# e.to_a #=> [1, 2, 3, 4, 5]
#
def +: [Elem2] (::_Each[Elem2]) -> ::Enumerator::Chain[Elem | Elem2]
def +: [Elem2] (::_Each[Elem2]) -> ::Enumerator::Chain[E | Elem2]

# <!--
# rdoc-file=enumerator.c
Expand All @@ -514,8 +514,8 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
# `offset`
# : the starting index to use
#
def with_index: (?Integer offset) { (Elem arg0, Integer arg1) -> untyped } -> Return
| (?Integer offset) -> ::Enumerator[[ Elem, Integer ], Return]
def with_index: (?Integer offset) { (E arg0, Integer arg1) -> untyped } -> R
| (?Integer offset) -> ::Enumerator[[ E, Integer ], R]

# <!-- rdoc-file=enumerator.c -->
# Iterates the given block for each element with an arbitrary object, `obj`, and
Expand All @@ -540,17 +540,17 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
# # => foo: 1
# # => foo: 2
#
def with_object: [U] (U obj) { (Elem, U obj) -> untyped } -> U
| [U] (U obj) -> ::Enumerator[[ Elem, U ], U]
def with_object: [U] (U obj) { (E, U obj) -> untyped } -> U
| [U] (U obj) -> ::Enumerator[[ E, U ], U]
end

# <!-- rdoc-file=enumerator.c -->
# Generator
#
class Enumerator::Generator[out Elem] < Object
include Enumerable[Elem]
class Enumerator::Generator[out E] < Object
include Enumerable[E]

def each: () { (Elem) -> void } -> void
def each: () { (E) -> void } -> void
end

# <!-- rdoc-file=enumerator.c -->
Expand Down Expand Up @@ -619,7 +619,7 @@ end
# # This returns an array of items like a normal enumerator does.
# all_checked = active_items.select(&:checked)
#
class Enumerator::Lazy[out Elem, out Return = void] < Enumerator[Elem, Return]
class Enumerator::Lazy[out E, out R = void] < Enumerator[E, R]
# <!-- rdoc-file=enumerator.c -->
# Expands `lazy` enumerator to an array. See Enumerable#to_a.
#
Expand All @@ -631,15 +631,15 @@ class Enumerator::Lazy[out Elem, out Return = void] < Enumerator[Elem, Return]
# -->
# Like Enumerable#compact, but chains operation to be lazy-evaluated.
#
def compact: () -> Enumerator::Lazy[Elem, Return]
def compact: () -> Enumerator::Lazy[E, R]

# <!--
# rdoc-file=enumerator.c
# - lzy.eager -> enum
# -->
# Returns a non-lazy Enumerator converted from the lazy enumerator.
#
def eager: () -> ::Enumerator[Elem, Return]
def eager: () -> ::Enumerator[E, R]
end

# <!-- rdoc-file=enumerator.c -->
Expand Down Expand Up @@ -674,7 +674,7 @@ end
#
# This type of objects can be created by Enumerable#chain and Enumerator#+.
#
class Enumerator::Chain[out Elem] < Enumerator[Elem, void]
class Enumerator::Chain[out E] < Enumerator[E, void]
# <!--
# rdoc-file=enumerator.c
# - Enumerator::Chain.new(*enums) -> enum
Expand All @@ -686,7 +686,7 @@ class Enumerator::Chain[out Elem] < Enumerator[Elem, void]
# e.to_a #=> [1, 2, 3, 4, 5]
# e.size #=> 5
#
def initialize: (*_Each[Elem] enums) -> void
def initialize: (*_Each[E] enums) -> void

# <!--
# rdoc-file=enumerator.c
Expand All @@ -699,6 +699,6 @@ class Enumerator::Chain[out Elem] < Enumerator[Elem, void]
#
# If no block is given, returns an enumerator.
#
def each: () { (Elem) -> void } -> self
| () -> Enumerator[Elem, self]
def each: () { (E) -> void } -> self
| () -> Enumerator[E, self]
end
10 changes: 5 additions & 5 deletions core/enumerator/product.rbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%a{annotate:rdoc:skip}
class Enumerator[unchecked out Elem, out Return = void]
class Enumerator[unchecked out E, out R = void]
# <!-- rdoc-file=enumerator.c -->
# Enumerator::Product generates a Cartesian product of any number of enumerable
# objects. Iterating over the product of enumerable objects is roughly
Expand Down Expand Up @@ -30,7 +30,7 @@ class Enumerator[unchecked out Elem, out Return = void]
#
# This type of objects can be created by Enumerator.product.
#
class Product[unchecked out Elem] < Enumerator[Array[Elem], Product[Elem]]
class Product[unchecked out E] < Enumerator[Array[E], Product[E]]
# <!--
# rdoc-file=enumerator.c
# - Enumerator::Product.new(*enums) -> enum
Expand All @@ -42,7 +42,7 @@ class Enumerator[unchecked out Elem, out Return = void]
# e.to_a #=> [[1, 4], [1, 5], [2, 4], [2, 5], [3, 4], [3, 5]]
# e.size #=> 6
#
def initialize: (*_EachEntry[Elem]) -> void
def initialize: (*_EachEntry[E]) -> void

# <!--
# rdoc-file=enumerator.c
Expand All @@ -55,7 +55,7 @@ class Enumerator[unchecked out Elem, out Return = void]
#
# If no block is given, returns an enumerator. Otherwise, returns self.
#
def each: () { (Array[Elem]) -> void } -> self
def each: () { (Array[E]) -> void } -> self

# <!--
# rdoc-file=enumerator.c
Expand Down Expand Up @@ -87,6 +87,6 @@ class Enumerator[unchecked out Elem, out Return = void]

private

def initialize_copy: (Product[Elem]) -> void
def initialize_copy: (Product[E]) -> void
end
end
14 changes: 7 additions & 7 deletions core/object_space/weak_key_map.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module ObjectSpace
# attributes always, but the values that aren't needed anymore wouldn't be
# sitting in the cache forever.
#
class WeakKeyMap[Key, Value]
class WeakKeyMap[K, V]
# <!--
# rdoc-file=weakmap.c
# - map[key] -> value
Expand All @@ -66,7 +66,7 @@ module ObjectSpace
#
# If `key` is not found, returns `nil`.
#
def []: (Key) -> Value?
def []: (K) -> V?

# <!--
# rdoc-file=weakmap.c
Expand All @@ -80,7 +80,7 @@ module ObjectSpace
# If the given `key` exists, replaces its value with the given `value`; the
# ordering is not affected
#
def []=: (Key, Value?) -> Value?
def []=: (K, V?) -> V?

# <!--
# rdoc-file=weakmap.c
Expand Down Expand Up @@ -119,8 +119,8 @@ module ObjectSpace
# m = ObjectSpace::WeakKeyMap.new
# m.delete("nosuch") { |key| "Key #{key} not found" } # => "Key nosuch not found"
#
def delete: (Key) -> Value?
| [T] (Key) { (Key) -> T } -> (Value | T)
def delete: (K) -> V?
| [T] (K) { (K) -> T } -> (V | T)

# <!--
# rdoc-file=weakmap.c
Expand All @@ -141,7 +141,7 @@ module ObjectSpace
# copy = cache.getkey({amount: 1, currency: 'USD'})
# copy.object_id == value.object_id #=> true
#
def getkey: (untyped) -> Key?
def getkey: (untyped) -> K?

# <!--
# rdoc-file=weakmap.c
Expand All @@ -161,6 +161,6 @@ module ObjectSpace
# -->
# Returns `true` if `key` is a key in `self`, otherwise `false`.
#
def key?: (Key) -> bool
def key?: (K) -> bool
end
end
Loading
Loading