From: Owen Avery Date: Fri, 12 May 2023 07:14:29 +0000 (-0400) Subject: gccrs: Allow hashing Optional X-Git-Tag: basepoints/gcc-15~2542 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3bbc4ca198c61d31e47ab493dbfd5a0eb1d97d31;p=thirdparty%2Fgcc.git gccrs: Allow hashing Optional gcc/rust/ChangeLog: * util/rust-optional.h (struct std::hash>): New. Signed-off-by: Owen Avery --- diff --git a/gcc/rust/util/rust-optional.h b/gcc/rust/util/rust-optional.h index 3b3f110b773e..658d90faa87f 100644 --- a/gcc/rust/util/rust-optional.h +++ b/gcc/rust/util/rust-optional.h @@ -228,6 +228,18 @@ public: } // namespace Rust +namespace std { + +template struct hash> +{ + size_t operator() (const Rust::Optional &op) const + { + return op.is_some () ? std::hash () (op.get ()) : 0; + } +}; + +} // namespace std + #ifdef CHECKING_P void