public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-7597] gccrs: Allow hashing Optional<T>
@ 2024-01-16 17:43 Arthur Cohen
  0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 17:43 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:3bbc4ca198c61d31e47ab493dbfd5a0eb1d97d31

commit r14-7597-g3bbc4ca198c61d31e47ab493dbfd5a0eb1d97d31
Author: Owen Avery <powerboat9.gamer@gmail.com>
Date:   Fri May 12 03:14:29 2023 -0400

    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>

Diff:
---
 gcc/rust/util/rust-optional.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/gcc/rust/util/rust-optional.h b/gcc/rust/util/rust-optional.h
index 3b3f110b773..658d90faa87 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-16 17:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 17:43 [gcc r14-7597] gccrs: Allow hashing Optional<T> Arthur Cohen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).