diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2023-05-12 03:14:29 -0400 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2023-05-17 16:08:00 +0000 |
commit | 6dd946dc1150df377f65367f78ef0b507f0438bd (patch) | |
tree | ace8c0846cba3c245b9a7b310c4f703bc36157ac | |
parent | 86dc0a1a1f6df906d1885de17d634aaa2ac08f08 (diff) | |
download | gcc-6dd946dc1150df377f65367f78ef0b507f0438bd.zip gcc-6dd946dc1150df377f65367f78ef0b507f0438bd.tar.gz gcc-6dd946dc1150df377f65367f78ef0b507f0438bd.tar.bz2 |
Allow hashing Optional<T>
gcc/rust/ChangeLog:
* util/rust-optional.h
(struct std::hash<Optional<T>>): New.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
-rw-r--r-- | gcc/rust/util/rust-optional.h | 12 |
1 files changed, 12 insertions, 0 deletions
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 <typename T> struct hash<Rust::Optional<T>> +{ + size_t operator() (const Rust::Optional<T> &op) const + { + return op.is_some () ? std::hash<T> () (op.get ()) : 0; + } +}; + +} // namespace std + #ifdef CHECKING_P void |