Skip to content

Commit

Permalink
Add test for #456 and fix bitflags glob import (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
juntyr committed May 21, 2023
1 parent ec889b5 commit 8fa9995
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
}
}

fn deserialize_seq<V>(mut self, visitor: V) -> Result<V::Value>
fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value>
where
V: Visitor<'de>,
{
Expand All @@ -543,7 +543,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
}
}

fn deserialize_tuple<V>(mut self, _len: usize, visitor: V) -> Result<V::Value>
fn deserialize_tuple<V>(self, _len: usize, visitor: V) -> Result<V::Value>
where
V: Visitor<'de>,
{
Expand Down Expand Up @@ -585,7 +585,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
})
}

fn deserialize_map<V>(mut self, visitor: V) -> Result<V::Value>
fn deserialize_map<V>(self, visitor: V) -> Result<V::Value>
where
V: Visitor<'de>,
{
Expand Down
27 changes: 27 additions & 0 deletions tests/115_minimal_flattening.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,30 @@ AllOptional({

assert_eq!(de, val);
}

#[derive(Clone, Debug, Default, Deserialize, PartialEq, Eq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct AvailableCards {
pub left: u8,
pub right: u8,
}

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
struct MapProperties {
#[serde(flatten)]
cards: AvailableCards,
}

#[test]
fn test_issue_456() {
let map_properties = MapProperties {
cards: AvailableCards {
..Default::default()
},
};
let ron = ron::to_string(&map_properties).unwrap();

let de: MapProperties = ron::from_str(&ron).unwrap();

assert_eq!(map_properties, de);
}
2 changes: 1 addition & 1 deletion tests/152_bitflags.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bitflags::*;
use bitflags::bitflags;
use option_set::option_set;

bitflags! {
Expand Down

0 comments on commit 8fa9995

Please sign in to comment.