From 6dd946dc1150df377f65367f78ef0b507f0438bd Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Fri, 12 May 2023 03:14:29 -0400 Subject: 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') diff --git a/gcc/rust/util/rust-optional.h b/gcc/rust/util/rust-optional.h index 01a5ff0..7276c48 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