resolve: Avoid some unstable iteration
This commit is contained in:
parent
f7b4354283
commit
a891139df1
9 changed files with 51 additions and 41 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue