@@ -467,10 +467,6 @@ impl[T] Option[T] {
467
467
... is Some(value) { value }
468
468
... is None { alt };
469
469
470
- @pub fun has(val: T): Bool = if self
471
- ... is Some(actual) { actual === val }
472
- ... is None { false };
473
-
474
470
@pub fun all(fct: (T): Bool): Bool = if self
475
471
... is Some(val) { fct(val) }
476
472
... is None { true };
@@ -514,6 +510,12 @@ impl[T: Identity] Identity for Option[T] {
514
510
@pub fun identicalTo(rhs: Option[T]): Bool = self === rhs;
515
511
}
516
512
513
+ impl[T: Identity] Option[T] {
514
+ @pub fun includes(val: T): Bool = if self
515
+ ... is Some(actual) { actual.identicalTo(val) }
516
+ ... is None { false };
517
+ }
518
+
517
519
impl[T: Equals] Equals for Option[T] {
518
520
@pub fun equals(rhs: Option[T]): Bool {
519
521
if self.isSome() {
@@ -585,10 +587,6 @@ impl[T, E] Result[T, E] {
585
587
... is Ok(_) { fatalError("cannot unwrap Ok."); unreachable[E]() }
586
588
... is Err(value) { value };
587
589
588
- @pub fun has(val: T): Bool = if self
589
- ... is Ok(actual) { actual === val }
590
- ... is Err(_) { false };
591
-
592
590
@pub fun all(fct: (T): Bool): Bool = if self
593
591
... is Ok(val) { fct(val) }
594
592
... is Err(_) { true };
@@ -634,6 +632,12 @@ impl[T: Identity, E] Identity for Result[T, E] {
634
632
@pub fun identicalTo(rhs: Result[T, E]): Bool = self === rhs;
635
633
}
636
634
635
+ impl[T: Identity, E] Result[T, E] {
636
+ @pub fun includes(val: T): Bool = if self
637
+ ... is Ok(actual) { actual.identicalTo(val) }
638
+ ... is Err(_) { false };
639
+ }
640
+
637
641
impl[T: Equals, E] Result[T, E] {
638
642
@pub fun contains(rhs: T): Bool = if self
639
643
... is Ok(val) { val.equals(rhs) }
0 commit comments