Ord for Id (#5176)

This commit is contained in:
Connor Fitzgerald 2024-02-01 03:29:34 -05:00
parent e029858a18
commit 9ca3e936db
No known key found for this signature in database
GPG Key ID: CF0A1F83B4E1A995
2 changed files with 18 additions and 0 deletions

View File

@ -63,6 +63,11 @@ Bottom level categories:
## v0.19.2 (2024-02-29)
### Added/New Features
#### General
- `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
#### General

View File

@ -74,6 +74,7 @@ mod macros;
use std::{
any::Any,
borrow::Cow,
cmp::Ordering,
error, fmt,
future::Future,
marker::PhantomData,
@ -4948,6 +4949,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)