Skip to content

Commit

Permalink
Fixed spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
vigna committed Nov 6, 2023
1 parent 469fd3b commit ecb7909
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 46 deletions.
64 changes: 20 additions & 44 deletions epserde-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,33 +170,19 @@ pub fn epserde_derive(input: TokenStream) -> TokenStream {
generics_name_vec,
generics,
..
} = CommonDeriveInput::new(derive_input.clone(),
vec![],
);
} = CommonDeriveInput::new(derive_input.clone(), vec![]);

// Values for serialize (we add serialization bounds to generics)
let CommonDeriveInput {
generics: generics_serialize,
..
} = CommonDeriveInput::new(
derive_input.clone(),
vec![
//syn::parse_quote!(epserde::prelude::TypeHash),
//syn::parse_quote!(epserde::prelude::ReprHash)
],
);
} = CommonDeriveInput::new(derive_input.clone(), vec![]);

// Values for deserialize (we add deserialization bounds to generics)
let CommonDeriveInput {
generics: generics_deserialize,
..
} = CommonDeriveInput::new(
derive_input.clone(),
vec![
//syn::parse_quote!(epserde::prelude::TypeHash),
//syn::parse_quote!(epserde::prelude::ReprHash)
],
);
} = CommonDeriveInput::new(derive_input.clone(), vec![]);

let out = match derive_input.data {
Data::Struct(s) => {
Expand Down Expand Up @@ -266,30 +252,26 @@ pub fn epserde_derive(input: TokenStream) -> TokenStream {
fields_types.iter().for_each(|ty| {
// add that every struct field has to implement SerializeInner
let mut bounds_ser = Punctuated::new();
bounds_ser.push(
syn::parse_quote!(epserde::ser::SerializeInner)
);
where_clause_ser.predicates.push(
WherePredicate::Type(PredicateType {
lifetimes: None,
bounded_ty: (*ty).clone(),
bounds_ser.push(syn::parse_quote!(epserde::ser::SerializeInner));
where_clause_ser
.predicates
.push(WherePredicate::Type(PredicateType {
lifetimes: None,
bounded_ty: (*ty).clone(),
colon_token: token::Colon::default(),
bounds: bounds_ser,
})
);
}));
// add that every struct field has to implement DeserializeInner
let mut bounds_des = Punctuated::new();
bounds_des.push(
syn::parse_quote!(epserde::deser::DeserializeInner)
);
where_clause_des.predicates.push(
WherePredicate::Type(PredicateType {
lifetimes: None,
bounded_ty: (*ty).clone(),
bounds_des.push(syn::parse_quote!(epserde::deser::DeserializeInner));
where_clause_des
.predicates
.push(WherePredicate::Type(PredicateType {
lifetimes: None,
bounded_ty: (*ty).clone(),
colon_token: token::Colon::default(),
bounds: bounds_des,
})
);
}));
});

// We add to the deserialization where clause the bounds on the deserialization
Expand Down Expand Up @@ -466,29 +448,23 @@ pub fn epserde_type_hash(input: TokenStream) -> TokenStream {
..
} = CommonDeriveInput::new(
input.clone(),
vec![
syn::parse_quote!(epserde::traits::TypeHash),
],
vec![syn::parse_quote!(epserde::traits::TypeHash)],
);

let CommonDeriveInput {
generics: generics_reprhash,
..
} = CommonDeriveInput::new(
input.clone(),
vec![
syn::parse_quote!(epserde::traits::ReprHash),
],
vec![syn::parse_quote!(epserde::traits::ReprHash)],
);

let CommonDeriveInput {
generics: generics_maxsizeof,
..
} = CommonDeriveInput::new(
input.clone(),
vec![
syn::parse_quote!(epserde::traits::MaxSizeOf),
],
vec![syn::parse_quote!(epserde::traits::MaxSizeOf)],
);

let out = match input.data {
Expand Down
2 changes: 1 addition & 1 deletion epserde/src/impls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ pub mod prim;
pub mod slice;
pub mod string;
pub mod tuple;
#[cfg(any(feature="alloc", feature="std"))]
#[cfg(any(feature = "alloc", feature = "std"))]
pub mod vec;
2 changes: 1 addition & 1 deletion epserde/tests/test_phantom.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![cfg(test)]

use core::marker::PhantomData;
use epserde::prelude::*;
use epserde::TypeInfo;
use core::marker::PhantomData;

#[test]
/// Test that we can serialize and desertialize a PhantomData
Expand Down

0 comments on commit ecb7909

Please sign in to comment.