Commit f9ea1ae6 authored by Benjamin Woodruff's avatar Benjamin Woodruff

Turbopack: Implement Ord for ResolvedVc and OperationVc

parent ff89de45
...@@ -281,7 +281,9 @@ pub struct UpdateInfo { ...@@ -281,7 +281,9 @@ pub struct UpdateInfo {
placeholder_for_future_fields: (), placeholder_for_future_fields: (),
} }
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize, Encode, Decode)] #[derive(
Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, Serialize, Deserialize, Encode, Decode,
)]
pub enum TaskPersistence { pub enum TaskPersistence {
/// Tasks that may be persisted across sessions using serialization. /// Tasks that may be persisted across sessions using serialization.
Persistent, Persistent,
......
...@@ -25,7 +25,9 @@ use crate::{ ...@@ -25,7 +25,9 @@ use crate::{
turbo_tasks, turbo_tasks,
}; };
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Encode, Decode)] #[derive(
Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Encode, Decode,
)]
pub struct CellId { pub struct CellId {
pub type_id: ValueTypeId, pub type_id: ValueTypeId,
pub index: u32, pub index: u32,
...@@ -47,7 +49,9 @@ impl Display for CellId { ...@@ -47,7 +49,9 @@ impl Display for CellId {
/// ///
/// [`Vc`]: crate::Vc /// [`Vc`]: crate::Vc
/// [monomorphization]: https://doc.rust-lang.org/book/ch10-01-syntax.html#performance-of-code-using-generics /// [monomorphization]: https://doc.rust-lang.org/book/ch10-01-syntax.html#performance-of-code-using-generics
#[derive(Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Encode, Decode)] #[derive(
Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Encode, Decode,
)]
pub enum RawVc { pub enum RawVc {
/// The synchronous return value of a task (after argument resolution). This is the /// The synchronous return value of a task (after argument resolution). This is the
/// representation used by [`OperationVc`][crate::OperationVc]. /// representation used by [`OperationVc`][crate::OperationVc].
......
use std::{ use std::{
cmp::Ordering,
fmt::Debug, fmt::Debug,
future::Future, future::Future,
hash::Hash, hash::Hash,
...@@ -221,6 +222,24 @@ where ...@@ -221,6 +222,24 @@ where
impl<T> Eq for OperationVc<T> where T: ?Sized {} impl<T> Eq for OperationVc<T> where T: ?Sized {}
impl<T> PartialOrd<OperationVc<T>> for OperationVc<T>
where
T: ?Sized,
{
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl<T> Ord for OperationVc<T>
where
T: ?Sized,
{
fn cmp(&self, other: &Self) -> Ordering {
self.node.node.cmp(&other.node.node)
}
}
impl<T> Debug for OperationVc<T> impl<T> Debug for OperationVc<T>
where where
T: ?Sized, T: ?Sized,
......
use std::{ use std::{
any::Any, any::Any,
cmp::Ordering,
fmt::Debug, fmt::Debug,
future::IntoFuture, future::IntoFuture,
hash::{Hash, Hasher}, hash::{Hash, Hasher},
...@@ -132,6 +133,24 @@ where ...@@ -132,6 +133,24 @@ where
impl<T> Eq for ResolvedVc<T> where T: ?Sized {} impl<T> Eq for ResolvedVc<T> where T: ?Sized {}
impl<T> PartialOrd<ResolvedVc<T>> for ResolvedVc<T>
where
T: ?Sized,
{
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl<T> Ord for ResolvedVc<T>
where
T: ?Sized,
{
fn cmp(&self, other: &Self) -> Ordering {
self.node.node.cmp(&other.node.node)
}
}
impl<T> Hash for ResolvedVc<T> impl<T> Hash for ResolvedVc<T>
where where
T: ?Sized, T: ?Sized,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment