Ord for Id (#5176)

This commit is contained in:
Connor Fitzgerald 2024-02-01 03:29:34 -05:00 committed by GitHub
parent 87b6513df3
commit d0c52d70fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -99,6 +99,7 @@ Bottom level categories:
-wgpu::Instance::any_backend_feature_enabled()
+!wgpu::Instance::enabled_backend_features().is_empty()
```
- `wgpu::Id` now implements `PartialOrd`/`Ord` allowing it to be put in `BTreeMap`s. By @cwfitzgerald and @9291Sam in [#5176](https://github.com/gfx-rs/wgpu/pull/5176)
### Bug Fixes

View File

@ -75,6 +75,7 @@ mod macros;
use std::{
any::Any,
borrow::Cow,
cmp::Ordering,
error, fmt,
future::Future,
marker::PhantomData,
@ -4971,6 +4972,18 @@ impl<T> PartialEq for Id<T> {
impl<T> Eq for Id<T> {}
impl<T> PartialOrd for Id<T> {
fn partial_cmp(&self, other: &Id<T>) -> Option<Ordering> {
self.0.partial_cmp(&other.0)
}
}
impl<T> Ord for Id<T> {
fn cmp(&self, other: &Id<T>) -> Ordering {
self.0.cmp(&other.0)
}
}
impl<T> std::hash::Hash for Id<T> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.0.hash(state)