Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Commit 86074a9

Browse files
committed
stdlib: add missing Identity blanket impl for Option and Result
works on #88
1 parent 593e35a commit 86074a9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

dora/stdlib/primitives.dora

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std.traits.{Default, Equals, Hash, Iterator, Zero};
1+
use std.traits.{Default, Equals, Hash, Identity, Iterator, Zero};
22
use std.string.Stringable;
33
use std.fatalError;
44

@@ -510,6 +510,10 @@ impl[T] Option[Option[T]] {
510510
... is None { None[T] };
511511
}
512512

513+
impl[T: Identity] Identity for Option[T] {
514+
@pub fun identicalTo(rhs: Option[T]): Bool = self === rhs;
515+
}
516+
513517
impl[T: Equals] Equals for Option[T] {
514518
@pub fun equals(rhs: Option[T]): Bool {
515519
if self.isSome() {
@@ -626,6 +630,10 @@ impl[T, E] Result[T, E] {
626630
... is Err(_) { None[T] };
627631
}
628632

633+
impl[T: Identity, E] Identity for Result[T, E] {
634+
@pub fun identicalTo(rhs: Result[T, E]): Bool = self === rhs;
635+
}
636+
629637
impl[T: Equals, E] Result[T, E] {
630638
@pub fun contains(rhs: T): Bool = if self
631639
... is Ok(val) { val.equals(rhs) }

0 commit comments

Comments
 (0)