Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Unreleased

- Fix: Multiple `#[derive(CachDiff)]` calls in the same file now work (https://github.com/heroku-buildpacks/cache_diff/pull/4)

## 1.0.0

- Changed: Error when deriving CacheDiff when zero comparison fields are found. This can happen if the struct has no fields or if all fields are `ignore`-d (https://github.com/schneems/cache_diff/pull/4)
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ members = [
]

[workspace.package]
version = "1.0.0"
version = "1.0.1"
rust-version = "1.82"
edition = "2021"
license = "Apache-2.0"
Expand Down
4 changes: 1 addition & 3 deletions cache_diff_derive/src/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ pub fn create_cache_diff(item: TokenStream) -> syn::Result<TokenStream> {
))
} else {
Ok(quote! {
#[allow(clippy::useless_attribute)]
use cache_diff as _cache_diff;
impl _cache_diff::CacheDiff for #struct_identifier {
impl cache_diff::CacheDiff for #struct_identifier {
fn diff(&self, old: &Self) -> Vec<String> {
let mut differences = Vec::new();
#(#comparisons)*
Expand Down
34 changes: 34 additions & 0 deletions usage/src/multiple_structs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Ensure multiple derives can be in the same file
#[derive(CacheDiff)]
struct Dog {
woof: String,
}
#[allow(dead_code)]
#[derive(CacheDiff)]
struct Cat {
meow: String,
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_cat() {
let diff = Cat {
meow: "Meow".to_string(),
}
.diff(&Cat {
meow: "Woem".to_string(),
});
assert!(diff.len() == 1);
}
#[test]
fn test_dog() {
let diff = Dog {
woof: "Woof".to_string(),
}
.diff(&Dog {
woof: "Foow".to_string(),
});
assert!(diff.len() == 1);
}
}