-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a minimum viable
ResolvedVc
type (vercel/turborepo#8661)
### Description We want a way to more strongly guarantee that a `Vc` is resolved for the sake of "local" tasks. This introduces it in a low-risk way with zero breaking changes. Eventually, we'd want to eliminate `.resolve()` or make `.resolve()` return `ResolvedVc` instead of using a separate `.to_resolved()` method. Some rough notes about why here: https://www.notion.so/vercel/Resolved-Vcs-Vc-Lifetimes-Local-Vcs-and-Vc-Refcounts-49d666d3f9594017b5b312b87ddc5bff ### Testing Instructions Tested as a part of vercel/turborepo#8678
- Loading branch information
Showing
3 changed files
with
57 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use std::{ | ||
hash::{Hash, Hasher}, | ||
ops::Deref, | ||
}; | ||
|
||
use crate::vc::Vc; | ||
|
||
#[derive(Copy, Clone)] | ||
pub struct ResolvedVc<T> | ||
where | ||
T: ?Sized + Send, | ||
{ | ||
pub(crate) node: Vc<T>, | ||
} | ||
|
||
impl<T> Deref for ResolvedVc<T> | ||
where | ||
T: ?Sized + Send, | ||
{ | ||
type Target = Vc<T>; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.node | ||
} | ||
} | ||
|
||
impl<T> Hash for ResolvedVc<T> | ||
where | ||
T: ?Sized + Send, | ||
{ | ||
fn hash<H: Hasher>(&self, state: &mut H) { | ||
self.node.hash(state); | ||
} | ||
} |