Skip to content

Commit fb5e01d

Browse files
committed
Removed some comments & cargo fmt
1 parent 57e6866 commit fb5e01d

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

examples/enum.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use serde_diff::{Apply, Diff, SerdeDiff};
33

44
#[derive(SerdeDiff, Serialize, Deserialize, PartialEq, Debug)]
55
enum TestEnum {
6-
Structish {x : u32, y: u32},
7-
Enumish (i32, i32, i32),
6+
Structish { x: u32, y: u32 },
7+
Enumish(i32, i32, i32),
88
Unitish,
99
}
1010

@@ -19,7 +19,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
1919
let mut deserializer = serde_json::Deserializer::from_str(&json_data);
2020
let mut target = TestEnum::Structish { x: 0, y: 4 };
2121
Apply::apply(&mut deserializer, &mut target)?;
22-
22+
2323
let result = TestEnum::Structish { x: 8, y: 4 };
2424
assert_eq!(result, target);
2525
}
@@ -31,30 +31,30 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
3131
};
3232
let json_data = serde_json::to_string(&Diff::serializable(&old, &new))?;
3333
let mut deserializer = serde_json::Deserializer::from_str(&json_data);
34-
let mut target = TestEnum::Enumish ( 1, 2, 3);
34+
let mut target = TestEnum::Enumish(1, 2, 3);
3535
Apply::apply(&mut deserializer, &mut target)?;
36-
/* we can't apply changes from one enum variant
36+
/* we can't apply changes from one enum variant
3737
to another, as there may be unfilled fields with no sane defaults,
3838
should there be an error? probably.*/
39-
let result = TestEnum::Enumish ( 1, 2, 3);
39+
let result = TestEnum::Enumish(1, 2, 3);
4040
assert_eq!(result, target);
4141
}
4242
{
43-
let old = TestEnum::Enumish (1, 2, 3);
44-
let new = TestEnum::Enumish (1, 10, 3);
43+
let old = TestEnum::Enumish(1, 2, 3);
44+
let new = TestEnum::Enumish(1, 10, 3);
4545
let json_data = serde_json::to_string(&Diff::serializable(&old, &new))?;
4646
let mut deserializer = serde_json::Deserializer::from_str(&json_data);
47-
let mut target = TestEnum::Enumish ( 4, 3, 2);
47+
let mut target = TestEnum::Enumish(4, 3, 2);
4848
Apply::apply(&mut deserializer, &mut target)?;
49-
let result = TestEnum::Enumish (4, 10, 2);
49+
let result = TestEnum::Enumish(4, 10, 2);
5050
assert_eq!(result, target);
5151
}
5252
{
5353
let old = TestEnum::Structish { x: 5, y: 2 };
5454
let new = TestEnum::Unitish;
5555
let json_data = serde_json::to_string(&Diff::serializable(&old, &new))?;
5656
let mut deserializer = serde_json::Deserializer::from_str(&json_data);
57-
let mut target = TestEnum::Enumish ( 1, 2, 3);
57+
let mut target = TestEnum::Enumish(1, 2, 3);
5858
Apply::apply(&mut deserializer, &mut target)?;
5959
let result = TestEnum::Unitish;
6060
assert_eq!(result, target);

examples/struct.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ struct Test3Struct;
1313

1414
#[derive(SerdeDiff, Serialize, Deserialize, PartialEq, Debug)]
1515
struct Test4Struct<T>
16-
where T: SerdeDiff
16+
where
17+
T: SerdeDiff,
1718
{
1819
a: T,
1920
}
@@ -34,18 +35,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
3435
assert_eq!(result, target);
3536
}
3637
{
37-
let old = Test2Struct (1, 2, 3);
38-
let new = Test2Struct (
38+
let old = Test2Struct(1, 2, 3);
39+
let new = Test2Struct(
3940
5, // Differs from old.0, will be serialized
40-
2,
41-
3
41+
2, 3,
4242
);
43-
let mut target = Test2Struct (4,5,6);
43+
let mut target = Test2Struct(4, 5, 6);
4444
let json_data = serde_json::to_string(&Diff::serializable(&old, &new))?;
4545
let mut deserializer = serde_json::Deserializer::from_str(&json_data);
4646
Apply::apply(&mut deserializer, &mut target)?;
4747

48-
let result = Test2Struct ( 5,5,6 );
48+
let result = Test2Struct(5, 5, 6);
4949
assert_eq!(result, target);
5050
}
5151
{
@@ -60,14 +60,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
6060
assert_eq!(result, target);
6161
}
6262
{
63-
let old = Test4Struct { a: 5};
64-
let new = Test4Struct { a: 7};
65-
let mut target = Test4Struct { a: 10};
63+
let old = Test4Struct { a: 5 };
64+
let new = Test4Struct { a: 7 };
65+
let mut target = Test4Struct { a: 10 };
6666
let json_data = serde_json::to_string(&Diff::serializable(&old, &new))?;
6767
let mut deserializer = serde_json::Deserializer::from_str(&json_data);
6868
Apply::apply(&mut deserializer, &mut target)?;
6969

70-
let result = Test4Struct { a: 7};
70+
let result = Test4Struct { a: 7 };
7171
assert_eq!(result, target);
7272
}
7373
Ok(())

serde-diff-derive/src/serde_diff/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub fn macro_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
1919
} else {
2020
// Go ahead and generate the code
2121
match generate(&input, struct_args) {
22-
//Ok(v) => {eprintln!("{}", v); v},
2322
Ok(v) => v,
2423
Err(v) => v,
2524
}
@@ -31,7 +30,6 @@ pub fn macro_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
3130
} else {
3231
// Go ahead and generate the code
3332
match generate(&input, struct_args) {
34-
//Ok(v) => {eprintln!("{}", v); v},
3533
Ok(v) => v,
3634
Err(v) => v,
3735
}
@@ -270,7 +268,7 @@ fn generate_arms(name: &syn::Ident, variant: Option<&syn::Ident>, fields: &syn::
270268
while let Some(element) = ctx.next_path_element(seq)? {
271269
match element {
272270
#(#apply_fn_field_handlers)*
273-
_ => ctx.skip_value(seq)?
271+
_ => ctx.skip_value(seq)?
274272
}
275273
}
276274
}

src/difference.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,18 @@ impl<'a, S: SerializeSeq> DiffContext<'a, S> {
7171
self.element_stack
7272
.as_mut()
7373
.unwrap()
74-
.push(ElementStackEntry::PathElement(DiffPathElementValue::EnumVariant(
75-
Cow::Borrowed(variant_name),
76-
)));
74+
.push(ElementStackEntry::PathElement(
75+
DiffPathElementValue::EnumVariant(Cow::Borrowed(variant_name)),
76+
));
7777
}
7878

7979
pub fn push_full_variant(&mut self) {
8080
self.element_stack
8181
.as_mut()
8282
.unwrap()
83-
.push(ElementStackEntry::PathElement(DiffPathElementValue::FullEnumVariant));
83+
.push(ElementStackEntry::PathElement(
84+
DiffPathElementValue::FullEnumVariant,
85+
));
8486
}
8587

8688
/// Called when we visit a field. If the structure is recursive (i.e. struct within struct,

0 commit comments

Comments
 (0)