-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically derive ValueDefault for primitive value types (#5793)
### Description This PR automatically derives `ValueDefault` for primitive value types. This means that you can replace `Vc::<String>::empty()` with `Default::default()`. The same goes for all primitive value types (`bool`, `u8`, `()`, etc.). The underlying type's `Default` implementation will be used. ### Testing Instructions N/A Closes WEB-1430
- Loading branch information
Showing
4 changed files
with
64 additions
and
24 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
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 |
---|---|---|
@@ -1,15 +1,8 @@ | ||
use crate::{ValueDefault, Vc}; | ||
use crate::Vc; | ||
|
||
// TODO(alexkirsz) Should this be `#[turbo_tasks::function]` or is it okay to | ||
// always return a new `Vc`? | ||
#[deprecated(note = "use Default::default() instead")] | ||
pub fn unit() -> Vc<()> { | ||
Vc::cell(()) | ||
} | ||
|
||
impl ValueDefault for () { | ||
// TODO(alexkirsz) Should this be `#[turbo_tasks::function]` or is it | ||
// preferrable to always return a new `Vc`? | ||
fn value_default() -> Vc<Self> { | ||
Vc::cell(()) | ||
} | ||
} |