-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for deriving ContentHash for Enums
Here's an example of what the derived output looks like for an enum: ```rust pub enum TreeValue { File { id: FileId, executable: bool }, Symlink(SymlinkId), Tree(TreeId), GitSubmodule(CommitId), Conflict(ConflictId), } #[automatically_derived] impl ::jj_lib::content_hash::ContentHash for TreeValue { fn hash(&self, state: &mut impl digest::Update) { match self { Self::File { id, executable } => { state.update(&0u32.to_le_bytes()); ::jj_lib::content_hash::ContentHash::hash(id, state); ::jj_lib::content_hash::ContentHash::hash(executable, state); } Self::Symlink(field_0) => { state.update(&1u32.to_le_bytes()); ::jj_lib::content_hash::ContentHash::hash(field_0, state); } Self::Tree(field_0) => { state.update(&2u32.to_le_bytes()); ::jj_lib::content_hash::ContentHash::hash(field_0, state); } Self::GitSubmodule(field_0) => { state.update(&3u32.to_le_bytes()); ::jj_lib::content_hash::ContentHash::hash(field_0, state); } Self::Conflict(field_0) => { state.update(&4u32.to_le_bytes()); ::jj_lib::content_hash::ContentHash::hash(field_0, state); } } } } ``` #3054
- Loading branch information
1 parent
40558ce
commit b9331eb
Showing
3 changed files
with
92 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ proc-macro = true | |
proc-macro2 = { workspace=true } | ||
quote = { workspace=true } | ||
syn = { workspace=true } | ||
|
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