Maintain backward compatibility with Rust 1.15, take 3.
This commit is contained in:
parent
752bf0d4a1
commit
cd6373a9ab
|
@ -568,7 +568,8 @@ impl<'de> de::Deserializer<'de> for ValueDeserializer<'de> {
|
|||
match &self.value.e {
|
||||
&E::InlineTable(ref values) | &E::DottedTable(ref values) => {
|
||||
let extra_fields = values.iter()
|
||||
.filter_map(|(ref key, ref _val)| {
|
||||
.filter_map(|key_value| {
|
||||
let (ref key, ref _val) = *key_value;
|
||||
if !fields.contains(&&(**key)) {
|
||||
Some(key.clone())
|
||||
} else {
|
||||
|
|
|
@ -22,8 +22,7 @@ struct Multi {
|
|||
|
||||
#[test]
|
||||
fn invalid_variant_returns_error_with_good_message_string() {
|
||||
let error = toml::from_str::<TheEnum>("\"NonExistent\"")
|
||||
.expect_err("Expected deserialization to fail.");
|
||||
let error = toml::from_str::<TheEnum>("\"NonExistent\"").unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error.to_string(),
|
||||
|
@ -33,8 +32,7 @@ fn invalid_variant_returns_error_with_good_message_string() {
|
|||
|
||||
#[test]
|
||||
fn invalid_variant_returns_error_with_good_message_inline_table() {
|
||||
let error = toml::from_str::<TheEnum>("{ NonExistent = {} }")
|
||||
.expect_err("Expected deserialization to fail.");
|
||||
let error = toml::from_str::<TheEnum>("{ NonExistent = {} }").unwrap_err();
|
||||
assert_eq!(
|
||||
error.to_string(),
|
||||
"unknown variant `NonExistent`, expected one of `Plain`, `Tuple`, `NewType`, `Struct`"
|
||||
|
@ -43,8 +41,7 @@ fn invalid_variant_returns_error_with_good_message_inline_table() {
|
|||
|
||||
#[test]
|
||||
fn extra_field_returns_expected_empty_table_error() {
|
||||
let error = toml::from_str::<TheEnum>("{ Plain = { extra_field = 404 } }")
|
||||
.expect_err("Expected deserialization to fail.");
|
||||
let error = toml::from_str::<TheEnum>("{ Plain = { extra_field = 404 } }").unwrap_err();
|
||||
|
||||
assert_eq!(error.to_string(), "expected empty table");
|
||||
}
|
||||
|
@ -52,7 +49,7 @@ fn extra_field_returns_expected_empty_table_error() {
|
|||
#[test]
|
||||
fn extra_field_returns_expected_empty_table_error_struct_variant() {
|
||||
let error = toml::from_str::<TheEnum>("{ Struct = { value = 123, extra_0 = 0, extra_1 = 1 } }")
|
||||
.expect_err("Expected deserialization to fail.");
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error.to_string(),
|
||||
|
|
Loading…
Reference in a new issue