mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-23 03:38:00 +00:00
Merge pull request #311 from dtolnay/deserialize_with
Field with deserialize_with should not implement Deserialize
This commit is contained in:
@@ -308,22 +308,6 @@ impl FieldAttrs {
|
||||
&self.name
|
||||
}
|
||||
|
||||
/// Predicate for using a field's default value
|
||||
pub fn expr_is_missing(&self) -> P<ast::Expr> {
|
||||
match self.default_expr_if_missing {
|
||||
Some(ref expr) => expr.clone(),
|
||||
None => {
|
||||
let name = self.name.deserialize_name_expr();
|
||||
AstBuilder::new().expr()
|
||||
.try()
|
||||
.method_call("missing_field").id("visitor")
|
||||
.with_arg(name)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Predicate for ignoring a field when serializing a value
|
||||
pub fn skip_serializing_field(&self) -> bool {
|
||||
self.skip_serializing_field
|
||||
}
|
||||
@@ -336,6 +320,10 @@ impl FieldAttrs {
|
||||
self.skip_serializing_field_if.as_ref()
|
||||
}
|
||||
|
||||
pub fn default_expr_if_missing(&self) -> Option<&P<ast::Expr>> {
|
||||
self.default_expr_if_missing.as_ref()
|
||||
}
|
||||
|
||||
pub fn serialize_with(&self) -> Option<&P<ast::Expr>> {
|
||||
self.serialize_with.as_ref()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user