diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2023-05-12 03:14:29 -0400 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 18:37:19 +0100 |
commit | 3bbc4ca198c61d31e47ab493dbfd5a0eb1d97d31 (patch) | |
tree | 01116e57f9fe4c52566888ebcd0d1f23df1fb104 /gcc/rust/util/rust-optional.h | |
parent | 122f519ceb12a142983dd381d3a42058a11fce22 (diff) | |
download | gcc-3bbc4ca198c61d31e47ab493dbfd5a0eb1d97d31.zip gcc-3bbc4ca198c61d31e47ab493dbfd5a0eb1d97d31.tar.gz gcc-3bbc4ca198c61d31e47ab493dbfd5a0eb1d97d31.tar.bz2 |
gccrs: 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>
Diffstat (limited to 'gcc/rust/util/rust-optional.h')
-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 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 <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 |