|
| 1 | +module Rs |
| 2 | + # https://doc.rust-lang.org/std/option/index.html |
| 3 | + # https://doc.rust-lang.org/std/option/enum.Option.html |
| 4 | + # https://doc.rust-lang.org/src/core/option.rs.html |
| 5 | + class Option |
| 6 | + class TypeError < StandardError |
| 7 | + def initialize: (untyped value_type) -> void |
| 8 | + end |
| 9 | + |
| 10 | + class TypeNilClass < StandardError |
| 11 | + end |
| 12 | + |
| 13 | + class TypeMismatch < StandardError |
| 14 | + end |
| 15 | + |
| 16 | + class WrapNil < StandardError |
| 17 | + end |
| 18 | + |
| 19 | + class UnwrapNone < StandardError |
| 20 | + end |
| 21 | + |
| 22 | + def is_some: () -> untyped |
| 23 | + |
| 24 | + def is_some_and: () { (?) -> untyped } -> (untyped | false) |
| 25 | + |
| 26 | + def is_none: () -> untyped |
| 27 | + |
| 28 | + def is_none_or: () { (?) -> untyped } -> (true | untyped) |
| 29 | + |
| 30 | + def expect: (untyped msg) -> untyped |
| 31 | + |
| 32 | + def unwrap: () -> untyped |
| 33 | + |
| 34 | + def unwrap_or: (untyped default) -> untyped |
| 35 | + |
| 36 | + def unwrap_or_else: () { (?) -> untyped } -> untyped |
| 37 | + |
| 38 | + def map: (untyped value_type) { (?) -> untyped } -> untyped |
| 39 | + |
| 40 | + def map_or: (untyped default) { (?) -> untyped } -> untyped |
| 41 | + |
| 42 | + def map_or_else: (untyped default) { (?) -> untyped } -> untyped |
| 43 | + |
| 44 | + def ok_or: (untyped error) -> untyped |
| 45 | + |
| 46 | + def ok_or_else: () { (?) -> untyped } -> untyped |
| 47 | + |
| 48 | + def and: (untyped other) -> untyped |
| 49 | + |
| 50 | + def and_then: (untyped value_type) { (?) -> untyped } -> untyped |
| 51 | + |
| 52 | + def select: () { (?) -> untyped } -> (self | untyped | untyped) |
| 53 | + |
| 54 | + def or: (untyped other) -> (self | untyped) |
| 55 | + |
| 56 | + def or_else: () { (?) -> untyped } -> (self | untyped) |
| 57 | + |
| 58 | + def xor: (untyped other) -> untyped |
| 59 | + |
| 60 | + def tap: () { (?) -> untyped } -> self |
| 61 | + |
| 62 | + def self.from: (untyped value_type) { (?) -> untyped } -> untyped |
| 63 | + |
| 64 | + def self.from?: (untyped value_type) { (?) -> untyped } -> untyped |
| 65 | + |
| 66 | + def self.from!: (untyped value_type) { (?) -> untyped } -> untyped |
| 67 | + end |
| 68 | +end |
| 69 | + |
| 70 | +class Some < Rs::Option |
| 71 | + @value: untyped |
| 72 | + |
| 73 | + @value_type: untyped |
| 74 | + |
| 75 | + attr_reader value_type: untyped |
| 76 | + |
| 77 | + def self.[]: (untyped value_type) { (?) -> untyped } -> untyped |
| 78 | + |
| 79 | + def inspect: () -> ::String |
| 80 | + |
| 81 | + def ==: (untyped other) -> untyped |
| 82 | + |
| 83 | + def initialize: (untyped value) -> void |
| 84 | +end |
| 85 | + |
| 86 | +class None < Rs::Option |
| 87 | + @value_type: untyped |
| 88 | + |
| 89 | + attr_reader value_type: untyped |
| 90 | + |
| 91 | + def self.[]: (untyped value_type) -> untyped |
| 92 | + |
| 93 | + def inspect: () -> ::String |
| 94 | + |
| 95 | + def ==: (untyped other) -> untyped |
| 96 | + |
| 97 | + def initialize: (?untyped value_type) -> void |
| 98 | +end |
0 commit comments