Skip to content

Commit

Permalink
feat: support serde::skip_deserializing
Browse files Browse the repository at this point in the history
  • Loading branch information
wspeirs committed Oct 9, 2023
1 parent f038043 commit 58d7093
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use quote::quote;
use serde_derive_internals::{attr::get_serde_meta_items, Ctxt};
use syn::{parse_macro_input, Data, DataStruct, DeriveInput, Fields, Ident, Lit, Meta, NestedMeta};

/// Parses `#[serde(skip_serializing)]`
/// Parses `#[serde(skip_serializing)]` and `#[serde(skip_deserializing)]`
fn serde_skipped(cx: &Ctxt, attrs: &[syn::Attribute]) -> bool {
for meta_items in attrs
.iter()
Expand All @@ -12,12 +12,13 @@ fn serde_skipped(cx: &Ctxt, attrs: &[syn::Attribute]) -> bool {
for meta_item in meta_items {
match meta_item {
NestedMeta::Meta(Meta::Path(path))
if path
.get_ident()
.map_or(false, |i| *i == "skip_serializing") =>
{
return true
}
if path
.get_ident()
// will not work with skip_serializing_if
.map_or(false, |i| *i == "skip_serializing" || *i == "skip_deserializing") =>
{
return true
}
_ => continue,
}
}
Expand Down

0 comments on commit 58d7093

Please sign in to comment.