Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update rust 1.84.0 #74

Merged
merged 3 commits into from
Jan 10, 2025
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
9 changes: 8 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ jobs:
run: nix develop -c cargo fmt

- name: Lint
run: nix develop -c cargo clippy -- -Dwarnings
run: |
nix develop -c cargo clippy -- -Dwarnings
nix develop -c cargo clippy --no-default-features -- -Dwarnings
nix develop -c cargo clippy --features=std -- -Dwarnings
nix develop -c cargo clippy --features=merge -- -Dwarnings
nix develop -c cargo clippy --features=option -- -Dwarnings
nix develop -c cargo clippy --features=none_as_default -- -Dwarnings
nix develop -c cargo clippy --features=keep_none -- -Dwarnings
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]
authors = ["Antonio Yang <yanganto@gmail.com>"]
version = "0.8.6"
version = "0.8.7"
edition = "2021"
categories = ["development-tools"]
keywords = ["struct", "patch", "macro", "derive", "overlay"]
Expand Down
24 changes: 12 additions & 12 deletions flake.lock

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

52 changes: 45 additions & 7 deletions struct-patch-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,48 @@ impl Patch {
})
.collect::<Vec<_>>();

#[cfg(feature = "op")]
#[cfg(all(feature = "op", not(feature = "merge")))]
let op_impl = quote! {
impl #generics core::ops::Shl<#name #generics> for #struct_name #generics #where_clause {
type Output = Self;

fn shl(mut self, rhs: #name #generics) -> Self {
struct_patch::traits::Patch::apply(&mut self, rhs);
self
}
}

impl #generics core::ops::Add<Self> for #name #generics #where_clause {
type Output = Self;

fn add(mut self, rhs: Self) -> Self {
Self {
#(
#renamed_field_names: match (self.#renamed_field_names, rhs.#renamed_field_names) {
(Some(a), Some(b)) => {
#addable_handles
},
(Some(a), None) => Some(a),
(None, Some(b)) => Some(b),
(None, None) => None,
},
)*
#(
#original_field_names: match (self.#original_field_names, rhs.#original_field_names) {
(Some(a), Some(b)) => {
#addable_handles
},
(Some(a), None) => Some(a),
(None, Some(b)) => Some(b),
(None, None) => None,
},
)*
}
}
}
};

#[cfg(feature = "merge")]
let op_impl = quote! {
impl #generics core::ops::Shl<#name #generics> for #struct_name #generics #where_clause {
type Output = Self;
Expand All @@ -166,7 +207,6 @@ impl Patch {
}
}

#[cfg(feature = "merge")]
impl #generics core::ops::Shl<#name #generics> for #name #generics #where_clause {
type Output = Self;

Expand Down Expand Up @@ -204,6 +244,7 @@ impl Patch {
}
}
};

#[cfg(not(feature = "op"))]
let op_impl = quote!();

Expand Down Expand Up @@ -446,7 +487,7 @@ impl Field {
ADDABLE => {
return Err(syn::Error::new(
ident.span(),
"`addable` needs `op` feature"
"`addable` needs `op` feature",
));
}
#[cfg(feature = "op")]
Expand All @@ -457,10 +498,7 @@ impl Field {
}
#[cfg(not(feature = "op"))]
ADD => {
return Err(syn::Error::new(
ident.span(),
"`add` needs `op` feature"
));
return Err(syn::Error::new(ident.span(), "`add` needs `op` feature"));
}
_ => {
return Err(meta.error(format_args!(
Expand Down
2 changes: 1 addition & 1 deletion struct-patch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license.workspace = true
readme.workspace = true

[dependencies]
struct-patch-derive = { version = "=0.8.6", path = "../struct-patch-derive" }
struct-patch-derive = { version = "=0.8.7", path = "../struct-patch-derive" }

[dev-dependencies]
serde_json = "1.0"
Expand Down
6 changes: 3 additions & 3 deletions struct-patch/examples/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn main() {

item.apply(patch);

assert_eq!(item.field_complete, false);
assert!(!item.field_complete);
assert_eq!(item.field_int, 7);
assert_eq!(item.field_string, "");

Expand All @@ -44,7 +44,7 @@ fn main() {
};
let new_item = item << another_patch;

assert_eq!(new_item.field_complete, false);
assert!(!new_item.field_complete);
assert_eq!(new_item.field_int, 7);
assert_eq!(new_item.field_string, "from another patch");

Expand All @@ -54,7 +54,7 @@ fn main() {
field_string: None,
};
let final_item = new_item << the_other_patch;
assert_eq!(final_item.field_complete, true);
assert!(final_item.field_complete);
assert_eq!(final_item.field_int, 7);
assert_eq!(final_item.field_string, "from another patch");
}
Expand Down
8 changes: 2 additions & 6 deletions struct-patch/examples/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ fn main() {
field_bool: true,
field_int: 42,
field_string: String::from("hello"),
sub: SubItem {
inner_int: 0
},
sub: SubItem { inner_int: 0 },
};

let data = r#"{
Expand All @@ -43,9 +41,7 @@ fn main() {
field_bool: true,
field_int: 7,
field_string: String::from("hello"),
sub: SubItem {
inner_int: 7,
},
sub: SubItem { inner_int: 7 },
}
);
}
6 changes: 3 additions & 3 deletions struct-patch/examples/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn main() {

item.apply(patch);

assert_eq!(item.field_complete, false);
assert!(!item.field_complete);
assert_eq!(item.field_int, 7);
assert_eq!(item.field_string, "");

Expand Down Expand Up @@ -78,11 +78,11 @@ fn main() {
final_item_from_merge.field_string,
"from another patch, the other patch"
);
assert_eq!(final_item_from_merge.field_complete, true);
assert!(final_item_from_merge.field_complete);

let final_item_series_patch = item << another_patch << the_other_patch;
assert_eq!(final_item_series_patch.field_string, "the other patch");
assert_eq!(final_item_series_patch.field_complete, true);
assert!(final_item_series_patch.field_complete);
}

#[cfg(not(feature = "op"))]
Expand Down
2 changes: 1 addition & 1 deletion struct-patch/examples/time.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use serde::{Deserialize};
use serde::Deserialize;
use std::time::Duration;
use struct_patch::Patch;

Expand Down
Loading