From 014dd0304d9d2f0f32a390226470be4a876e903c Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Fri, 19 May 2023 13:15:34 -0400 Subject: gccrs: 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 66730bd..30880cd 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