rbs 4.1.0.pre.1 → 4.1.0.pre.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/c-check.yml +3 -0
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/jruby.yml +67 -0
- data/.github/workflows/milestone.yml +4 -1
- data/.github/workflows/ruby.yml +12 -0
- data/.github/workflows/rust.yml +3 -0
- data/.github/workflows/truffleruby.yml +54 -0
- data/.github/workflows/typecheck.yml +3 -0
- data/.github/workflows/wasm.yml +53 -0
- data/.github/workflows/windows.yml +6 -0
- data/.gitignore +7 -0
- data/README.md +3 -3
- data/Rakefile +116 -1
- data/Steepfile +7 -0
- data/core/array.rbs +144 -144
- data/core/builtin.rbs +6 -6
- data/core/enumerable.rbs +109 -109
- data/core/enumerator/product.rbs +5 -5
- data/core/enumerator.rbs +28 -28
- data/core/file.rbs +24 -1018
- data/core/file_constants.rbs +463 -0
- data/core/file_stat.rbs +534 -0
- data/core/hash.rbs +117 -101
- data/core/integer.rbs +21 -58
- data/core/io.rbs +25 -7
- data/core/module.rbs +88 -74
- data/core/numeric.rbs +3 -0
- data/core/object_space/weak_key_map.rbs +7 -7
- data/core/range.rbs +23 -23
- data/core/rbs/ops.rbs +154 -0
- data/core/rbs/unnamed/argf.rbs +3 -3
- data/core/set.rbs +3 -3
- data/core/struct.rbs +16 -16
- data/core/thread.rbs +6 -6
- data/docs/CONTRIBUTING.md +2 -1
- data/docs/inline.md +36 -6
- data/docs/rbs_by_example.md +20 -20
- data/docs/syntax.md +2 -2
- data/docs/wasm_serialization.md +80 -0
- data/ext/rbs_extension/ast_translation.c +1294 -973
- data/ext/rbs_extension/ast_translation.h +4 -0
- data/ext/rbs_extension/main.c +139 -4
- data/include/rbs/ast.h +9 -1
- data/include/rbs/serialize.h +39 -0
- data/lib/rbs/ast/ruby/comment_block.rb +6 -4
- data/lib/rbs/ast/ruby/helpers/location_helper.rb +1 -1
- data/lib/rbs/ast/ruby/members.rb +12 -1
- data/lib/rbs/buffer.rb +48 -11
- data/lib/rbs/collection/sources/git.rb +6 -0
- data/lib/rbs/definition_builder/method_builder.rb +12 -6
- data/lib/rbs/environment.rb +4 -3
- data/lib/rbs/inline_parser.rb +5 -3
- data/lib/rbs/namespace.rb +47 -11
- data/lib/rbs/prototype/runtime.rb +2 -0
- data/lib/rbs/resolver/type_name_resolver.rb +12 -14
- data/lib/rbs/type_name.rb +33 -13
- data/lib/rbs/unit_test/type_assertions.rb +9 -0
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/wasm/deserializer.rb +213 -0
- data/lib/rbs/wasm/location.rb +61 -0
- data/lib/rbs/wasm/parser.rb +137 -0
- data/lib/rbs/wasm/runtime.rb +217 -0
- data/lib/rbs/wasm/serialization_schema.rb +110 -0
- data/lib/rbs.rb +13 -2
- data/rbs.gemspec +19 -2
- data/sig/ast/ruby/members.rbs +6 -1
- data/sig/buffer.rbs +19 -1
- data/sig/namespace.rbs +20 -0
- data/sig/parser.rbs +10 -0
- data/sig/resolver/type_name_resolver.rbs +2 -4
- data/sig/typename.rbs +15 -0
- data/sig/unit_test/type_assertions.rbs +4 -0
- data/sig/wasm/deserializer.rbs +66 -0
- data/sig/wasm/serialization_schema.rbs +13 -0
- data/src/ast.c +78 -78
- data/src/lexstate.c +5 -1
- data/src/serialize.c +958 -0
- data/src/util/rbs_allocator.c +1 -4
- data/stdlib/abbrev/0/array.rbs +1 -1
- data/stdlib/csv/0/csv.rbs +5 -5
- data/stdlib/digest/0/digest.rbs +1 -1
- data/stdlib/etc/0/etc.rbs +18 -4
- data/stdlib/fileutils/0/fileutils.rbs +21 -21
- data/stdlib/json/0/json.rbs +6 -6
- data/stdlib/openssl/0/openssl.rbs +5 -5
- data/stdlib/resolv/0/resolv.rbs +1 -1
- data/stdlib/shellwords/0/shellwords.rbs +1 -1
- data/stdlib/stringio/0/stringio.rbs +32 -10
- data/stdlib/strscan/0/string_scanner.rbs +74 -55
- data/stdlib/tsort/0/cyclic.rbs +1 -1
- data/stdlib/tsort/0/interfaces.rbs +8 -8
- data/stdlib/tsort/0/tsort.rbs +9 -9
- data/stdlib/zlib/0/gzip_reader.rbs +2 -2
- data/wasm/README.md +59 -0
- data/wasm/rbs_wasm.c +411 -0
- metadata +21 -5
- data/.vscode/extensions.json +0 -5
- data/.vscode/settings.json +0 -19
data/core/hash.rbs
CHANGED
|
@@ -469,15 +469,29 @@
|
|
|
469
469
|
# * #transform_values: Returns a copy of `self` with modified values.
|
|
470
470
|
# * #transform_values!: Modifies values in `self`.
|
|
471
471
|
#
|
|
472
|
-
class Hash[unchecked out K, unchecked out V]
|
|
472
|
+
class Hash[unchecked out K, unchecked out V]
|
|
473
473
|
include Enumerable[[ K, V ]]
|
|
474
474
|
|
|
475
|
+
# Interface that indicates a type can be used as a key to `Hash` lookup methods.
|
|
476
|
+
#
|
|
475
477
|
interface _Key
|
|
476
478
|
def hash: () -> Integer
|
|
477
479
|
|
|
478
480
|
def eql?: (untyped rhs) -> boolish
|
|
479
481
|
end
|
|
480
482
|
|
|
483
|
+
# Interface that indicates a type convertible to `[ K, V ]` via its `#to_ary` method.
|
|
484
|
+
#
|
|
485
|
+
interface _Pair[K, V]
|
|
486
|
+
def to_ary: () -> [ K, V ]
|
|
487
|
+
end
|
|
488
|
+
|
|
489
|
+
# Interface for comparing equality of types.
|
|
490
|
+
#
|
|
491
|
+
interface _Equals
|
|
492
|
+
def ==: (untyped other) -> boolish
|
|
493
|
+
end
|
|
494
|
+
|
|
481
495
|
# <!--
|
|
482
496
|
# rdoc-file=hash.c
|
|
483
497
|
# - Hash[] -> new_empty_hash
|
|
@@ -514,9 +528,9 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
514
528
|
# See also [Methods for Creating a
|
|
515
529
|
# Hash](rdoc-ref:Hash@Methods+for+Creating+a+Hash).
|
|
516
530
|
#
|
|
517
|
-
def self.[]: [
|
|
518
|
-
| [
|
|
519
|
-
| (*
|
|
531
|
+
def self.[]: [K, V] (hash[K, V] hash) -> instance
|
|
532
|
+
| [K, V] (array[ _Pair[K, V] ] two_element_arrays) -> instance
|
|
533
|
+
| [T] (*T objects) -> Hash[T, T]
|
|
520
534
|
|
|
521
535
|
# <!--
|
|
522
536
|
# rdoc-file=hash.c
|
|
@@ -531,8 +545,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
531
545
|
# Otherwise if `object` does not respond to <code>:to_hash</code>, returns
|
|
532
546
|
# `nil`.
|
|
533
547
|
#
|
|
534
|
-
def self.try_convert: [
|
|
535
|
-
| (untyped) ->
|
|
548
|
+
def self.try_convert: [K, V] (hash[K, V] hash) -> Hash[K, V]
|
|
549
|
+
| (untyped) -> Hash[untyped, untyped]?
|
|
536
550
|
|
|
537
551
|
# <!--
|
|
538
552
|
# rdoc-file=hash.c
|
|
@@ -556,7 +570,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
556
570
|
#
|
|
557
571
|
# Related: see [Methods for Comparing](rdoc-ref:Hash@Methods+for+Comparing).
|
|
558
572
|
#
|
|
559
|
-
def <: [
|
|
573
|
+
def <: (hash[untyped, untyped] other_hash) -> bool
|
|
560
574
|
|
|
561
575
|
# <!--
|
|
562
576
|
# rdoc-file=hash.c
|
|
@@ -577,7 +591,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
577
591
|
#
|
|
578
592
|
# Related: see [Methods for Comparing](rdoc-ref:Hash@Methods+for+Comparing).
|
|
579
593
|
#
|
|
580
|
-
def <=: [
|
|
594
|
+
def <=: (hash[untyped, untyped] other_hash) -> bool
|
|
581
595
|
|
|
582
596
|
# <!--
|
|
583
597
|
# rdoc-file=hash.c
|
|
@@ -629,7 +643,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
629
643
|
#
|
|
630
644
|
# Related: see [Methods for Comparing](rdoc-ref:Hash@Methods+for+Comparing).
|
|
631
645
|
#
|
|
632
|
-
def >: [
|
|
646
|
+
def >: (hash[untyped, untyped] other_hash) -> bool
|
|
633
647
|
|
|
634
648
|
# <!--
|
|
635
649
|
# rdoc-file=hash.c
|
|
@@ -651,7 +665,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
651
665
|
#
|
|
652
666
|
# Related: see [Methods for Comparing](rdoc-ref:Hash@Methods+for+Comparing).
|
|
653
667
|
#
|
|
654
|
-
def >=: [
|
|
668
|
+
def >=: (hash[untyped, untyped] other_hash) -> bool
|
|
655
669
|
|
|
656
670
|
# <!--
|
|
657
671
|
# rdoc-file=hash.c
|
|
@@ -671,7 +685,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
671
685
|
# Related: #[]=; see also [Methods for
|
|
672
686
|
# Fetching](rdoc-ref:Hash@Methods+for+Fetching).
|
|
673
687
|
#
|
|
674
|
-
def []: %a{implicitly-returns-nil} (
|
|
688
|
+
def []: %a{implicitly-returns-nil} (_Key key) -> V
|
|
675
689
|
|
|
676
690
|
# <!--
|
|
677
691
|
# rdoc-file=hash.c
|
|
@@ -701,7 +715,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
701
715
|
# Related: #[]; see also [Methods for
|
|
702
716
|
# Assigning](rdoc-ref:Hash@Methods+for+Assigning).
|
|
703
717
|
#
|
|
704
|
-
def []=: (K
|
|
718
|
+
def []=: (K key, V value) -> V
|
|
705
719
|
|
|
706
720
|
# <!--
|
|
707
721
|
# rdoc-file=hash.c
|
|
@@ -739,8 +753,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
739
753
|
# Fetching](rdoc-ref:Hash@Methods+for+Fetching).
|
|
740
754
|
#
|
|
741
755
|
def any?: () -> bool
|
|
742
|
-
| (
|
|
743
|
-
| () { (K, V) -> boolish } -> bool
|
|
756
|
+
| (Enumerable::_Pattern pattern) -> bool
|
|
757
|
+
| () { ([ K, V ] pair) -> boolish } -> bool
|
|
744
758
|
|
|
745
759
|
# <!--
|
|
746
760
|
# rdoc-file=hash.c
|
|
@@ -756,7 +770,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
756
770
|
#
|
|
757
771
|
# Related: see [Methods for Fetching](rdoc-ref:Hash@Methods+for+Fetching).
|
|
758
772
|
#
|
|
759
|
-
def assoc: (
|
|
773
|
+
def assoc: (_Equals key) -> [ K, V ]?
|
|
760
774
|
|
|
761
775
|
# <!--
|
|
762
776
|
# rdoc-file=hash.c
|
|
@@ -779,7 +793,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
779
793
|
#
|
|
780
794
|
# Related: see [Methods for Deleting](rdoc-ref:Hash@Methods+for+Deleting).
|
|
781
795
|
#
|
|
782
|
-
def compact: () ->
|
|
796
|
+
def compact: () -> instance
|
|
783
797
|
|
|
784
798
|
# <!--
|
|
785
799
|
# rdoc-file=hash.c
|
|
@@ -845,7 +859,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
845
859
|
# - deconstruct_keys(p1)
|
|
846
860
|
# -->
|
|
847
861
|
#
|
|
848
|
-
def deconstruct_keys: (
|
|
862
|
+
def deconstruct_keys: (untyped) -> self
|
|
849
863
|
|
|
850
864
|
# <!--
|
|
851
865
|
# rdoc-file=hash.c
|
|
@@ -866,7 +880,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
866
880
|
# h[:foo] = "Hello"
|
|
867
881
|
# h.default(:foo) # => "No key foo"
|
|
868
882
|
#
|
|
869
|
-
def default: (?
|
|
883
|
+
def default: (?_Key key) -> V?
|
|
870
884
|
|
|
871
885
|
# <!--
|
|
872
886
|
# rdoc-file=hash.c
|
|
@@ -880,7 +894,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
880
894
|
#
|
|
881
895
|
# See [Hash Default](rdoc-ref:Hash@Hash+Default).
|
|
882
896
|
#
|
|
883
|
-
def default=: (V
|
|
897
|
+
def default=: (V default) -> V
|
|
884
898
|
|
|
885
899
|
# <!--
|
|
886
900
|
# rdoc-file=hash.c
|
|
@@ -893,7 +907,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
893
907
|
# h.default_proc = proc {|hash, key| "Default value for #{key}" }
|
|
894
908
|
# h.default_proc.class # => Proc
|
|
895
909
|
#
|
|
896
|
-
def default_proc: () -> (
|
|
910
|
+
def default_proc: () -> (^(self, _Key key) -> V)?
|
|
897
911
|
|
|
898
912
|
# <!--
|
|
899
913
|
# rdoc-file=hash.c
|
|
@@ -908,7 +922,9 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
908
922
|
# h.default_proc = nil
|
|
909
923
|
# h.default_proc # => nil
|
|
910
924
|
#
|
|
911
|
-
def default_proc=: (
|
|
925
|
+
def default_proc=: (nil) -> nil
|
|
926
|
+
| (^(self, _Key key) -> V proc) -> ^(self, _Key) -> V
|
|
927
|
+
| (_ToProc proc) -> Proc
|
|
912
928
|
|
|
913
929
|
# <!--
|
|
914
930
|
# rdoc-file=hash.c
|
|
@@ -942,8 +958,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
942
958
|
#
|
|
943
959
|
# Related: see [Methods for Deleting](rdoc-ref:Hash@Methods+for+Deleting).
|
|
944
960
|
#
|
|
945
|
-
def delete: (
|
|
946
|
-
| [
|
|
961
|
+
def delete: (_Key key) -> V?
|
|
962
|
+
| [T, K2 < _Key] (K2 key) { (K2 key) -> T } -> (T | V)
|
|
947
963
|
|
|
948
964
|
# <!--
|
|
949
965
|
# rdoc-file=hash.c
|
|
@@ -960,8 +976,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
960
976
|
#
|
|
961
977
|
# Related: see [Methods for Deleting](rdoc-ref:Hash@Methods+for+Deleting).
|
|
962
978
|
#
|
|
963
|
-
def delete_if: ()
|
|
964
|
-
| ()
|
|
979
|
+
def delete_if: () -> Enumerator[[ K, V ], self]
|
|
980
|
+
| () { (K key, V value) -> boolish } -> self
|
|
965
981
|
|
|
966
982
|
# <!--
|
|
967
983
|
# rdoc-file=hash.c
|
|
@@ -997,7 +1013,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
997
1013
|
#
|
|
998
1014
|
# Related: [Methods for Fetching](rdoc-ref:Hash@Methods+for+Fetching).
|
|
999
1015
|
#
|
|
1000
|
-
def dig: (
|
|
1016
|
+
def dig: (_Key key, *untyped identifiers) -> untyped
|
|
1001
1017
|
|
|
1002
1018
|
# <!-- rdoc-file=hash.c -->
|
|
1003
1019
|
# With a block given, calls the block with each key-value pair; returns `self`:
|
|
@@ -1015,8 +1031,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1015
1031
|
#
|
|
1016
1032
|
# Related: see [Methods for Iterating](rdoc-ref:Hash@Methods+for+Iterating).
|
|
1017
1033
|
#
|
|
1018
|
-
def each: ()
|
|
1019
|
-
| ()
|
|
1034
|
+
def each: () -> Enumerator[[ K, V ], self]
|
|
1035
|
+
| () { ([ K, V ] pair) -> void } -> self
|
|
1020
1036
|
|
|
1021
1037
|
# <!--
|
|
1022
1038
|
# rdoc-file=hash.c
|
|
@@ -1037,8 +1053,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1037
1053
|
#
|
|
1038
1054
|
# Related: see [Methods for Iterating](rdoc-ref:Hash@Methods+for+Iterating).
|
|
1039
1055
|
#
|
|
1040
|
-
def each_key: ()
|
|
1041
|
-
| ()
|
|
1056
|
+
def each_key: () -> Enumerator[K, self]
|
|
1057
|
+
| () { (K key) -> void } -> self
|
|
1042
1058
|
|
|
1043
1059
|
# <!--
|
|
1044
1060
|
# rdoc-file=hash.c
|
|
@@ -1081,8 +1097,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1081
1097
|
#
|
|
1082
1098
|
# Related: see [Methods for Iterating](rdoc-ref:Hash@Methods+for+Iterating).
|
|
1083
1099
|
#
|
|
1084
|
-
def each_value: ()
|
|
1085
|
-
| ()
|
|
1100
|
+
def each_value: () -> Enumerator[V, self]
|
|
1101
|
+
| () { (V value) -> void } -> self
|
|
1086
1102
|
|
|
1087
1103
|
# <!--
|
|
1088
1104
|
# rdoc-file=hash.c
|
|
@@ -1117,7 +1133,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1117
1133
|
#
|
|
1118
1134
|
# Related: see [Methods for Querying](rdoc-ref:Hash@Methods+for+Querying).
|
|
1119
1135
|
#
|
|
1120
|
-
def eql?: (untyped) -> bool
|
|
1136
|
+
def eql?: (untyped object) -> bool
|
|
1121
1137
|
|
|
1122
1138
|
# <!--
|
|
1123
1139
|
# rdoc-file=hash.c
|
|
@@ -1132,7 +1148,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1132
1148
|
#
|
|
1133
1149
|
# Related: see [Methods for Deleting](rdoc-ref:Hash@Methods+for+Deleting).
|
|
1134
1150
|
#
|
|
1135
|
-
def except: (*
|
|
1151
|
+
def except: (*_Key keys) -> Hash[K, V]
|
|
1136
1152
|
|
|
1137
1153
|
# <!--
|
|
1138
1154
|
# rdoc-file=hash.c
|
|
@@ -1161,9 +1177,9 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1161
1177
|
#
|
|
1162
1178
|
# Related: see [Methods for Fetching](rdoc-ref:Hash@Methods+for+Fetching).
|
|
1163
1179
|
#
|
|
1164
|
-
def fetch: (
|
|
1165
|
-
| [X] (
|
|
1166
|
-
| [X] (
|
|
1180
|
+
def fetch: (_Key key) -> V
|
|
1181
|
+
| [X] (_Key key, X default_value) -> (V | X)
|
|
1182
|
+
| [K2 < _Key, X] (K2 key) { (K2 key) -> X } -> (V | X)
|
|
1167
1183
|
|
|
1168
1184
|
# <!--
|
|
1169
1185
|
# rdoc-file=hash.c
|
|
@@ -1186,10 +1202,14 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1186
1202
|
#
|
|
1187
1203
|
# Related: see [Methods for Fetching](rdoc-ref:Hash@Methods+for+Fetching).
|
|
1188
1204
|
#
|
|
1189
|
-
def fetch_values: (*
|
|
1190
|
-
| [
|
|
1205
|
+
def fetch_values: (*_Key keys) -> Array[V]
|
|
1206
|
+
| [K2 < _Key, T] (*K2 keys) { (K2 key) -> T } -> Array[V | T]
|
|
1191
1207
|
|
|
1192
|
-
# <!--
|
|
1208
|
+
# <!--
|
|
1209
|
+
# rdoc-file=hash.c
|
|
1210
|
+
# - select {|key, value| ... } -> new_hash
|
|
1211
|
+
# - select -> new_enumerator
|
|
1212
|
+
# -->
|
|
1193
1213
|
# With a block given, calls the block with each entry's key and value; returns a
|
|
1194
1214
|
# new hash whose entries are those for which the block returns a truthy value:
|
|
1195
1215
|
#
|
|
@@ -1200,10 +1220,14 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1200
1220
|
#
|
|
1201
1221
|
# Related: see [Methods for Deleting](rdoc-ref:Hash@Methods+for+Deleting).
|
|
1202
1222
|
#
|
|
1203
|
-
def
|
|
1204
|
-
| ()
|
|
1223
|
+
def select: () -> Enumerator[[ K, V ], Hash[K, V]]
|
|
1224
|
+
| () { (K key, V value) -> boolish } -> Hash[K, V]
|
|
1205
1225
|
|
|
1206
|
-
# <!--
|
|
1226
|
+
# <!--
|
|
1227
|
+
# rdoc-file=hash.c
|
|
1228
|
+
# - select! {|key, value| ... } -> self or nil
|
|
1229
|
+
# - select! -> new_enumerator
|
|
1230
|
+
# -->
|
|
1207
1231
|
# With a block given, calls the block with each entry's key and value; removes
|
|
1208
1232
|
# from `self` each entry for which the block returns `false` or `nil`.
|
|
1209
1233
|
#
|
|
@@ -1217,8 +1241,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1217
1241
|
#
|
|
1218
1242
|
# Related: see [Methods for Deleting](rdoc-ref:Hash@Methods+for+Deleting).
|
|
1219
1243
|
#
|
|
1220
|
-
def
|
|
1221
|
-
| ()
|
|
1244
|
+
def select!: () -> Enumerator[[ K, V ], self?]
|
|
1245
|
+
| () { (K key, V value) -> boolish } -> self?
|
|
1222
1246
|
|
|
1223
1247
|
# <!--
|
|
1224
1248
|
# rdoc-file=hash.c
|
|
@@ -1254,9 +1278,9 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1254
1278
|
#
|
|
1255
1279
|
# Related: see [Methods for Converting](rdoc-ref:Hash@Methods+for+Converting).
|
|
1256
1280
|
#
|
|
1257
|
-
def flatten: () ->
|
|
1258
|
-
| (
|
|
1259
|
-
| (
|
|
1281
|
+
def flatten: (?1 level) -> Array[K | V]
|
|
1282
|
+
| (0 level) -> Array[[K, V]]
|
|
1283
|
+
| (int level) -> Array[untyped]
|
|
1260
1284
|
|
|
1261
1285
|
# <!-- rdoc-file=hash.c -->
|
|
1262
1286
|
# Returns whether `key` is a key in `self`:
|
|
@@ -1267,7 +1291,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1267
1291
|
#
|
|
1268
1292
|
# Related: [Methods for Querying](rdoc-ref:Hash@Methods+for+Querying).
|
|
1269
1293
|
#
|
|
1270
|
-
def has_key?: (_Key) -> bool
|
|
1294
|
+
def has_key?: (_Key key) -> bool
|
|
1271
1295
|
|
|
1272
1296
|
# <!--
|
|
1273
1297
|
# rdoc-file=hash.c
|
|
@@ -1277,7 +1301,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1277
1301
|
#
|
|
1278
1302
|
# Related: [Methods for Querying](rdoc-ref:Hash@Methods+for+Querying).
|
|
1279
1303
|
#
|
|
1280
|
-
def has_value?: (top
|
|
1304
|
+
def has_value?: (top value) -> bool
|
|
1281
1305
|
|
|
1282
1306
|
# <!--
|
|
1283
1307
|
# rdoc-file=hash.c
|
|
@@ -1343,7 +1367,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1343
1367
|
# Related: see [Methods for Transforming Keys and
|
|
1344
1368
|
# Values](rdoc-ref:Hash@Methods+for+Transforming+Keys+and+Values).
|
|
1345
1369
|
#
|
|
1346
|
-
def invert: () ->
|
|
1370
|
+
def invert: () -> Hash[V, K]
|
|
1347
1371
|
|
|
1348
1372
|
# <!--
|
|
1349
1373
|
# rdoc-file=hash.c
|
|
@@ -1361,8 +1385,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1361
1385
|
#
|
|
1362
1386
|
# Related: see [Methods for Deleting](rdoc-ref:Hash@Methods+for+Deleting).
|
|
1363
1387
|
#
|
|
1364
|
-
def keep_if: ()
|
|
1365
|
-
| ()
|
|
1388
|
+
def keep_if: () -> Enumerator[[ K, V ], self]
|
|
1389
|
+
| () { (K key, V value) -> boolish } -> self
|
|
1366
1390
|
|
|
1367
1391
|
# <!--
|
|
1368
1392
|
# rdoc-file=hash.c
|
|
@@ -1379,7 +1403,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1379
1403
|
#
|
|
1380
1404
|
# Related: see [Methods for Fetching](rdoc-ref:Hash@Methods+for+Fetching).
|
|
1381
1405
|
#
|
|
1382
|
-
def key: (
|
|
1406
|
+
def key: (_Equals) -> K?
|
|
1383
1407
|
|
|
1384
1408
|
# <!-- rdoc-file=hash.c -->
|
|
1385
1409
|
# Returns whether `key` is a key in `self`:
|
|
@@ -1403,16 +1427,19 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1403
1427
|
#
|
|
1404
1428
|
# Related: see [Methods for Fetching](rdoc-ref:Hash@Methods+for+Fetching).
|
|
1405
1429
|
#
|
|
1406
|
-
def keys: () ->
|
|
1430
|
+
def keys: () -> Array[K]
|
|
1407
1431
|
|
|
1408
|
-
# <!--
|
|
1432
|
+
# <!--
|
|
1433
|
+
# rdoc-file=hash.c
|
|
1434
|
+
# - size -> integer
|
|
1435
|
+
# -->
|
|
1409
1436
|
# Returns the count of entries in `self`:
|
|
1410
1437
|
#
|
|
1411
1438
|
# {foo: 0, bar: 1, baz: 2}.size # => 3
|
|
1412
1439
|
#
|
|
1413
1440
|
# Related: see [Methods for Querying](rdoc-ref:Hash@Methods+for+Querying).
|
|
1414
1441
|
#
|
|
1415
|
-
def
|
|
1442
|
+
def size: () -> Integer
|
|
1416
1443
|
|
|
1417
1444
|
# <!-- rdoc-file=hash.c -->
|
|
1418
1445
|
# Returns whether `key` is a key in `self`:
|
|
@@ -1467,8 +1494,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1467
1494
|
#
|
|
1468
1495
|
# Related: see [Methods for Assigning](rdoc-ref:Hash@Methods+for+Assigning).
|
|
1469
1496
|
#
|
|
1470
|
-
def merge: [A, B] (
|
|
1471
|
-
| [A, B, C] (
|
|
1497
|
+
def merge: [A, B] (*hash[A, B] other_hashes) -> Hash[A | K, B | V]
|
|
1498
|
+
| [A, B, C] (*hash[A, B] other_hashes) { (K key, V oldval, B newval) -> C } -> Hash[A | K, B | V | C]
|
|
1472
1499
|
|
|
1473
1500
|
# <!-- rdoc-file=hash.c -->
|
|
1474
1501
|
# Updates values and/or adds entries to `self`; returns `self`.
|
|
@@ -1511,8 +1538,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1511
1538
|
#
|
|
1512
1539
|
# Related: see [Methods for Assigning](rdoc-ref:Hash@Methods+for+Assigning).
|
|
1513
1540
|
#
|
|
1514
|
-
def merge!: (
|
|
1515
|
-
| (
|
|
1541
|
+
def merge!: (*hash[K, V] other_hashes) -> self
|
|
1542
|
+
| (*hash[K, V] other_hashes) { (K key, V oldval, V newval) -> V } -> self
|
|
1516
1543
|
|
|
1517
1544
|
# <!--
|
|
1518
1545
|
# rdoc-file=hash.c
|
|
@@ -1529,7 +1556,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1529
1556
|
#
|
|
1530
1557
|
# Related: see [Methods for Fetching](rdoc-ref:Hash@Methods+for+Fetching).
|
|
1531
1558
|
#
|
|
1532
|
-
def rassoc: (
|
|
1559
|
+
def rassoc: (_Equals value) -> [ K, V ]?
|
|
1533
1560
|
|
|
1534
1561
|
# <!--
|
|
1535
1562
|
# rdoc-file=hash.c
|
|
@@ -1544,6 +1571,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1544
1571
|
#
|
|
1545
1572
|
def rehash: () -> self
|
|
1546
1573
|
|
|
1574
|
+
def freeze: () -> self
|
|
1575
|
+
|
|
1547
1576
|
# <!--
|
|
1548
1577
|
# rdoc-file=hash.c
|
|
1549
1578
|
# - reject {|key, value| ... } -> new_hash
|
|
@@ -1561,8 +1590,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1561
1590
|
#
|
|
1562
1591
|
# Related: see [Methods for Deleting](rdoc-ref:Hash@Methods+for+Deleting).
|
|
1563
1592
|
#
|
|
1564
|
-
def reject: () ->
|
|
1565
|
-
| () { (K, V) -> boolish } ->
|
|
1593
|
+
def reject: () -> Enumerator[[ K, V ], Hash[K, V]]
|
|
1594
|
+
| () { (K key, V value) -> boolish } -> Hash[K, V]
|
|
1566
1595
|
|
|
1567
1596
|
# <!--
|
|
1568
1597
|
# rdoc-file=hash.c
|
|
@@ -1582,8 +1611,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1582
1611
|
#
|
|
1583
1612
|
# Related: see [Methods for Deleting](rdoc-ref:Hash@Methods+for+Deleting).
|
|
1584
1613
|
#
|
|
1585
|
-
def reject!: () ->
|
|
1586
|
-
| () { (K, V) -> boolish } -> self?
|
|
1614
|
+
def reject!: () -> Enumerator[[ K, V ], self?]
|
|
1615
|
+
| () { (K key, V value) -> boolish } -> self?
|
|
1587
1616
|
|
|
1588
1617
|
# <!-- rdoc-file=hash.c -->
|
|
1589
1618
|
# Replaces the entire contents of `self` with the contents of `other_hash`;
|
|
@@ -1602,13 +1631,9 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1602
1631
|
#
|
|
1603
1632
|
# Related: see [Methods for Assigning](rdoc-ref:Hash@Methods+for+Assigning).
|
|
1604
1633
|
#
|
|
1605
|
-
def replace: (
|
|
1634
|
+
def replace: (hash[K, V] other) -> self
|
|
1606
1635
|
|
|
1607
|
-
# <!--
|
|
1608
|
-
# rdoc-file=hash.c
|
|
1609
|
-
# - select {|key, value| ... } -> new_hash
|
|
1610
|
-
# - select -> new_enumerator
|
|
1611
|
-
# -->
|
|
1636
|
+
# <!-- rdoc-file=hash.c -->
|
|
1612
1637
|
# With a block given, calls the block with each entry's key and value; returns a
|
|
1613
1638
|
# new hash whose entries are those for which the block returns a truthy value:
|
|
1614
1639
|
#
|
|
@@ -1619,13 +1644,9 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1619
1644
|
#
|
|
1620
1645
|
# Related: see [Methods for Deleting](rdoc-ref:Hash@Methods+for+Deleting).
|
|
1621
1646
|
#
|
|
1622
|
-
alias select
|
|
1647
|
+
alias filter select
|
|
1623
1648
|
|
|
1624
|
-
# <!--
|
|
1625
|
-
# rdoc-file=hash.c
|
|
1626
|
-
# - select! {|key, value| ... } -> self or nil
|
|
1627
|
-
# - select! -> new_enumerator
|
|
1628
|
-
# -->
|
|
1649
|
+
# <!-- rdoc-file=hash.c -->
|
|
1629
1650
|
# With a block given, calls the block with each entry's key and value; removes
|
|
1630
1651
|
# from `self` each entry for which the block returns `false` or `nil`.
|
|
1631
1652
|
#
|
|
@@ -1639,7 +1660,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1639
1660
|
#
|
|
1640
1661
|
# Related: see [Methods for Deleting](rdoc-ref:Hash@Methods+for+Deleting).
|
|
1641
1662
|
#
|
|
1642
|
-
alias
|
|
1663
|
+
alias filter! select!
|
|
1643
1664
|
|
|
1644
1665
|
# <!--
|
|
1645
1666
|
# rdoc-file=hash.c
|
|
@@ -1658,17 +1679,14 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1658
1679
|
#
|
|
1659
1680
|
def shift: () -> [ K, V ]?
|
|
1660
1681
|
|
|
1661
|
-
# <!--
|
|
1662
|
-
# rdoc-file=hash.c
|
|
1663
|
-
# - size -> integer
|
|
1664
|
-
# -->
|
|
1682
|
+
# <!-- rdoc-file=hash.c -->
|
|
1665
1683
|
# Returns the count of entries in `self`:
|
|
1666
1684
|
#
|
|
1667
1685
|
# {foo: 0, bar: 1, baz: 2}.size # => 3
|
|
1668
1686
|
#
|
|
1669
1687
|
# Related: see [Methods for Querying](rdoc-ref:Hash@Methods+for+Querying).
|
|
1670
1688
|
#
|
|
1671
|
-
alias size
|
|
1689
|
+
alias length size
|
|
1672
1690
|
|
|
1673
1691
|
# <!--
|
|
1674
1692
|
# rdoc-file=hash.c
|
|
@@ -1682,7 +1700,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1682
1700
|
#
|
|
1683
1701
|
# Related: see [Methods for Deleting](rdoc-ref:Hash@Methods+for+Deleting).
|
|
1684
1702
|
#
|
|
1685
|
-
def slice: (*
|
|
1703
|
+
def slice: [K2 < _Key] (*K2 keys) -> Hash[K2, V]
|
|
1686
1704
|
|
|
1687
1705
|
# <!-- rdoc-file=hash.c -->
|
|
1688
1706
|
# Associates the given `object` with the given `key`; returns `object`.
|
|
@@ -1723,7 +1741,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1723
1741
|
#
|
|
1724
1742
|
# Related: see [Methods for Converting](rdoc-ref:Hash@Methods+for+Converting).
|
|
1725
1743
|
#
|
|
1726
|
-
def to_a: () ->
|
|
1744
|
+
def to_a: () -> Array[[ K, V ]]
|
|
1727
1745
|
|
|
1728
1746
|
# <!--
|
|
1729
1747
|
# rdoc-file=hash.c
|
|
@@ -1746,7 +1764,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1746
1764
|
# Related: see [Methods for Converting](rdoc-ref:Hash@Methods+for+Converting).
|
|
1747
1765
|
#
|
|
1748
1766
|
def to_h: () -> Hash[K, V]
|
|
1749
|
-
| [A, B] () { (K, V) -> [
|
|
1767
|
+
| [A, B] () { (K key, V value) -> _Pair[A, B] } -> Hash[A, B]
|
|
1750
1768
|
|
|
1751
1769
|
# <!--
|
|
1752
1770
|
# rdoc-file=hash.c
|
|
@@ -1870,9 +1888,9 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1870
1888
|
# Values](rdoc-ref:Hash@Methods+for+Transforming+Keys+and+Values).
|
|
1871
1889
|
#
|
|
1872
1890
|
def transform_keys: () -> Enumerator[K, Hash[untyped, V]]
|
|
1873
|
-
| [
|
|
1874
|
-
| [
|
|
1875
|
-
| [
|
|
1891
|
+
| [K2] (hash[_Key, K2] replacements) -> Hash[K | K2, V]
|
|
1892
|
+
| [K2] (hash[_Key, K2] replacements) { (K old_key) -> K2 } -> Hash[K2, V]
|
|
1893
|
+
| [K2] () { (K key) -> K2 } -> Hash[K2, V]
|
|
1876
1894
|
|
|
1877
1895
|
# <!--
|
|
1878
1896
|
# rdoc-file=hash.c
|
|
@@ -1965,9 +1983,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1965
1983
|
# Values](rdoc-ref:Hash@Methods+for+Transforming+Keys+and+Values).
|
|
1966
1984
|
#
|
|
1967
1985
|
def transform_keys!: () -> Enumerator[K, self]
|
|
1968
|
-
| (
|
|
1969
|
-
| () { (K) -> K } -> self
|
|
1970
|
-
| (Hash[K, K]) { (K) -> K } -> self
|
|
1986
|
+
| (hash[K, K] replacements) ?{ (K key) -> K } -> self
|
|
1987
|
+
| () { (K key) -> K } -> self
|
|
1971
1988
|
|
|
1972
1989
|
# <!--
|
|
1973
1990
|
# rdoc-file=hash.c
|
|
@@ -1988,7 +2005,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1988
2005
|
# Values](rdoc-ref:Hash@Methods+for+Transforming+Keys+and+Values).
|
|
1989
2006
|
#
|
|
1990
2007
|
def transform_values: () -> Enumerator[V, Hash[K, untyped]]
|
|
1991
|
-
| [
|
|
2008
|
+
| [V2] () { (V value) -> V2 } -> Hash[K, V2]
|
|
1992
2009
|
|
|
1993
2010
|
# <!--
|
|
1994
2011
|
# rdoc-file=hash.c
|
|
@@ -2011,7 +2028,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
2011
2028
|
# Values](rdoc-ref:Hash@Methods+for+Transforming+Keys+and+Values).
|
|
2012
2029
|
#
|
|
2013
2030
|
def transform_values!: () -> Enumerator[V, self]
|
|
2014
|
-
| () { (V) -> V } -> self
|
|
2031
|
+
| () { (V value) -> V } -> self
|
|
2015
2032
|
|
|
2016
2033
|
# <!--
|
|
2017
2034
|
# rdoc-file=hash.c
|
|
@@ -2078,7 +2095,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
2078
2095
|
#
|
|
2079
2096
|
# Related: see [Methods for Fetching](rdoc-ref:Hash@Methods+for+Fetching).
|
|
2080
2097
|
#
|
|
2081
|
-
def values: () ->
|
|
2098
|
+
def values: () -> Array[V]
|
|
2082
2099
|
|
|
2083
2100
|
# <!--
|
|
2084
2101
|
# rdoc-file=hash.c
|
|
@@ -2096,7 +2113,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
2096
2113
|
#
|
|
2097
2114
|
# Related: see [Methods for Fetching](rdoc-ref:Hash@Methods+for+Fetching).
|
|
2098
2115
|
#
|
|
2099
|
-
def values_at: (*
|
|
2116
|
+
def values_at: (*_Key arg0) -> Array[V?]
|
|
2100
2117
|
|
|
2101
2118
|
private
|
|
2102
2119
|
|
|
@@ -2139,9 +2156,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
2139
2156
|
# See also [Methods for Creating a
|
|
2140
2157
|
# Hash](rdoc-ref:Hash@Methods+for+Creating+a+Hash).
|
|
2141
2158
|
#
|
|
2142
|
-
def initialize: (?capacity: int) -> void
|
|
2143
|
-
| (
|
|
2144
|
-
| (?capacity: int) { (Hash[K, V] hash, K key) -> V } -> void
|
|
2159
|
+
def initialize: (?V default_value, ?capacity: int) -> void
|
|
2160
|
+
| (?capacity: int) { (instance hash, _Key key) -> V } -> void
|
|
2145
2161
|
|
|
2146
2162
|
# <!--
|
|
2147
2163
|
# rdoc-file=hash.c
|
|
@@ -2163,5 +2179,5 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
2163
2179
|
#
|
|
2164
2180
|
# Related: see [Methods for Assigning](rdoc-ref:Hash@Methods+for+Assigning).
|
|
2165
2181
|
#
|
|
2166
|
-
|
|
2182
|
+
alias initialize_copy replace
|
|
2167
2183
|
end
|