Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiburt committed Dec 8, 2021
1 parent 2aebd0c commit e7b8ddd
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@ impl<'p> Serialize for SerializePyObject<'p> {

macro_rules! add_to_map {
($map:ident, $key:ident, $value:ident) => {
if !self.include_none && ($value.is_none() || $key.is_none()) {
// in case of none we don't need to serialize anything
// we just ingore this field.
} else {
let ignore_none_entry = !self.include_none && ($value.is_none() || $key.is_none());
if !ignore_none_entry {
if $key.is_none() {
$map.serialize_key("null")?;
} else if let Ok(key) = $key.extract::<bool>() {
Expand All @@ -110,6 +108,7 @@ impl<'p> Serialize for SerializePyObject<'p> {
$key
)));
}

$map.serialize_value(&SerializePyObject {
py: self.py,
obj: $value,
Expand Down

0 comments on commit e7b8ddd

Please sign in to comment.