From 3bbc4ca198c61d31e47ab493dbfd5a0eb1d97d31 Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Fri, 12 May 2023 03:14:29 -0400 Subject: gccrs: Allow hashing Optional gcc/rust/ChangeLog: * util/rust-optional.h (struct std::hash>): New. Signed-off-by: Owen Avery --- gcc/rust/util/rust-optional.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gcc/rust/util/rust-optional.h') diff --git a/gcc/rust/util/rust-optional.h b/gcc/rust/util/rust-optional.h index 3b3f110..658d90f 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 -- cgit v1.1