#![allow( // clippy is broken and shows wrong warnings // clippy on stable does not know yet about the lint name
unknown_lints, // https://github.com/rust-lang/rust-clippy/issues/8867
clippy::derive_partial_eq_without_eq,
)]
externcrate alloc;
mod utils;
usecrate::utils::{check_deserialization, check_error_deserialization, is_equal}; use alloc::collections::{BTreeMap, BTreeSet}; use core::{cmp, iter::FromIterator as _}; use expect_test::expect; use fnv::{FnvHashMap as HashMap, FnvHashSet as HashSet}; use pretty_assertions::assert_eq; use serde::{Deserialize, Serialize};
// Different value and key always works
is_equal(
S(HashMap::from_iter(vec![(1, 1), (2, 2), (3, 3)])),
expect![[r#"
{ "1": 1, "3": 3, "2": 2
}"#]],
);
// Same value for different keys is ok
is_equal(
S(HashMap::from_iter(vec![(1, 1), (2, 1), (3, 1)])),
expect![[r#"
{ "1": 1, "3": 1, "2": 1
}"#]],
);
// Duplicate keys are an error
check_error_deserialization::<S>(
r#"{"1": 1, "2": 2, "1": 3}"#,
expect![[r#"invalid entry: found duplicate key at line 1 column 24"#]],
);
}
// Different value and key always works
is_equal(
S(BTreeMap::from_iter(vec![(1, 1), (2, 2), (3, 3)])),
expect![[r#"
{ "1": 1, "2": 2, "3": 3
}"#]],
);
// Same value for different keys is ok
is_equal(
S(BTreeMap::from_iter(vec![(1, 1), (2, 1), (3, 1)])),
expect![[r#"
{ "1": 1, "2": 1, "3": 1
}"#]],
);
// Duplicate keys are an error
check_error_deserialization::<S>(
r#"{"1": 1, "2": 2, "1": 3}"#,
expect![[r#"invalid entry: found duplicate key at line 1 column 24"#]],
);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.