-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
refactor: Align data type with other implementation. #21
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! 👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, thank you!
impl Serialize for Type { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
{ | ||
let type_serde = _serde::SerdeType::from(self); | ||
type_serde.serialize(serializer) | ||
} | ||
} | ||
|
||
impl<'de> Deserialize<'de> for Type { | ||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
{ | ||
let type_serde = _serde::SerdeType::deserialize(deserializer)?; | ||
Ok(Type::from(type_serde)) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we simplify this with:
#[serde(from = "_serde::SerdeType", into = "_serde::SerdeType")]
pub enum Type {
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried, but it seems that the generated code can't contains lifetime parameter. The code duplication is not much, so I prefer to keep current approach.
This refactor introduces two changes:
NestedField
in composite types such as struct, map, list to align with java/python implementation.