From 003ac98771e6f8c4ba6b9878a925f61cc9d6c6e5 Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Fri, 19 May 2023 13:15:34 -0400 Subject: Add operator== for Optional. gcc/rust/ChangeLog: * util/rust-optional.h (operator==): New for Optional == Optional. Signed-off-by: Owen Avery --- gcc/rust/util/rust-optional.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc') diff --git a/gcc/rust/util/rust-optional.h b/gcc/rust/util/rust-optional.h index e3593a1..d3dfb7f 100644 --- a/gcc/rust/util/rust-optional.h +++ b/gcc/rust/util/rust-optional.h @@ -250,6 +250,16 @@ public: } }; +template +bool +operator== (const Optional &t, const Optional &u) +{ + if (t.is_some ()) + return u.is_some () && t.get () == u.get (); + else + return u.is_none (); +} + } // namespace Rust namespace std { -- cgit v1.1