about summary refs log tree commit diff
path: root/compiler/rustc_data_structures
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-03-15 11:40:17 +0000
committerbors <bors@rust-lang.org>2025-03-15 11:40:17 +0000
commit4d30011f6c616be074ba655a75e5d55441232bbb (patch)
tree8c4907dddd7f6ec926f92e44247ba3f9534b8b4c /compiler/rustc_data_structures
parentaa95b9648ad0383a3fd73b5271dd86f848b7c00c (diff)
parent35aa49dead043e3ea9312f23c651f3360f954406 (diff)
Auto merge of #138532 - matthiaskrgr:rollup-mgcynqu, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #138283 (Enforce type of const param correctly in MIR typeck)
 - #138439 (feat: check ARG_MAX on Unix platforms)
 - #138502 (resolve: Avoid some unstable iteration)
 - #138514 (Remove fake borrows of refs that are converted into non-refs in `MakeByMoveBody`)
 - #138524 (Mark myself as unavailable for reviews temporarily)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_data_structures')
-rw-r--r--compiler/rustc_data_structures/src/unord.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_data_structures/src/unord.rs b/compiler/rustc_data_structures/src/unord.rs
index 14c3162165c..baa66cd7c85 100644
--- a/compiler/rustc_data_structures/src/unord.rs
+++ b/compiler/rustc_data_structures/src/unord.rs
@@ -259,6 +259,12 @@ impl<V: Eq + Hash> UnordSet<V> {
         self.inner.is_empty()
     }
 
+    /// If the set has only one element, returns it, otherwise returns `None`.
+    #[inline]
+    pub fn get_only(&self) -> Option<&V> {
+        if self.inner.len() == 1 { self.inner.iter().next() } else { None }
+    }
+
     #[inline]
     pub fn insert(&mut self, v: V) -> bool {
         self.inner.insert(v)