| 1 | use craterust-analyzer cargo schemars 1.2.2 crate/::preluderust-analyzer cargo schemars 1.2.2 prelude/::*; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::{BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#, HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#}; |
| 3 | |
| 4 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:, Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:)] |
| 5 | #[schemars(extend("pattern" = "^[0-9a-f]*$"))] |
| 6 | struct HexNumberrust-analyzer cargo schemars 1.2.2 map/HexNumber#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#); |
| 7 | |
| 8 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:, Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 9 | struct IndirectU32rust-analyzer cargo schemars 1.2.2 map/IndirectU32#(u32); |
| 10 | |
| 11 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:, Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 12 | enum Enumrust-analyzer cargo schemars 1.2.2 map/Enum# { |
| 13 | Unit1rust-analyzer cargo schemars 1.2.2 map/Enum#Unit1#, |
| 14 | Unit2rust-analyzer cargo schemars 1.2.2 map/Enum#Unit2#, |
| 15 | #[serderust-analyzer cargo schemars_derive 1.2.2 serde:(untagged)] |
| 16 | UntaggedI8rust-analyzer cargo schemars 1.2.2 map/Enum#UntaggedI8#(i8), |
| 17 | #[serderust-analyzer cargo schemars_derive 1.2.2 serde:(untagged)] |
| 18 | UntaggedIndirectU32rust-analyzer cargo schemars 1.2.2 map/Enum#UntaggedIndirectU32#(IndirectU32rust-analyzer cargo schemars 1.2.2 map/IndirectU32#), |
| 19 | } |
| 20 | |
| 21 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:, Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)] |
| 22 | struct Mapsrust-analyzer cargo schemars 1.2.2 map/Maps# { |
| 23 | s_maprust-analyzer cargo schemars 1.2.2 map/Maps#s_map.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, bool>, |
| 24 | i_maprust-analyzer cargo schemars 1.2.2 map/Maps#i_map.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<i8, bool>, |
| 25 | u_maprust-analyzer cargo schemars 1.2.2 map/Maps#u_map.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<u64, bool>, |
| 26 | pattern_maprust-analyzer cargo schemars 1.2.2 map/Maps#pattern_map.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<HexNumberrust-analyzer cargo schemars 1.2.2 map/HexNumber#, bool>, |
| 27 | enum_maprust-analyzer cargo schemars 1.2.2 map/Maps#enum_map.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Enumrust-analyzer cargo schemars 1.2.2 map/Enum#, bool>, |
| 28 | } |
| 29 | |
| 30 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 31 | fn mapsrust-analyzer cargo schemars 1.2.2 map/maps().() { |
| 32 | testrust-analyzer cargo schemars 1.2.2 test!!(Mapsrust-analyzer cargo schemars 1.2.2 map/Maps#) |
| 33 | .assert_snapshotrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_snapshot().() |
| 34 | .assert_allows_ser_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_ser_roundtrip().([Mapsrust-analyzer cargo schemars 1.2.2 map/Maps# { |
| 35 | s_maprust-analyzer cargo schemars 1.2.2 map/Maps#s_map.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::from_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][`FromIterator<(K, V)>`]from_iter().([("test".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), true)]), |
| 36 | i_maprust-analyzer cargo schemars 1.2.2 map/Maps#i_map.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::from_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`][`FromIterator<(K, V)>`]from_iter().([(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().123, true), (123, true)]), |
| 37 | u_maprust-analyzer cargo schemars 1.2.2 map/Maps#u_map.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::from_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][`FromIterator<(K, V)>`]from_iter().([(123, true)]), |
| 38 | pattern_maprust-analyzer cargo schemars 1.2.2 map/Maps#pattern_map.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::from_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`][`FromIterator<(K, V)>`]from_iter().([(HexNumberrust-analyzer cargo schemars 1.2.2 map/HexNumber#("b4df00d".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), true)]), |
| 39 | enum_maprust-analyzer cargo schemars 1.2.2 map/Maps#enum_map.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::from_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][`FromIterator<(K, V)>`]from_iter().([(Enumrust-analyzer cargo schemars 1.2.2 map/Enum#::Unit1rust-analyzer cargo schemars 1.2.2 map/Enum#Unit1#, true)]), |
| 40 | }]) |
| 41 | .assert_allows_ser_onlyrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_ser_only().( |
| 42 | // serde allow serializing untagged non-string newtype variants, but not deserializing them. |
| 43 | [ |
| 44 | Mapsrust-analyzer cargo schemars 1.2.2 map/Maps# { |
| 45 | enum_maprust-analyzer cargo schemars 1.2.2 map/Maps#enum_map.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::from_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][`FromIterator<(K, V)>`]from_iter().([(Enumrust-analyzer cargo schemars 1.2.2 map/Enum#::UntaggedI8rust-analyzer cargo schemars 1.2.2 map/Enum#UntaggedI8#(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().100), true)]), |
| 46 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo schemars 1.2.2 map/impl#[Maps][Default]default().() |
| 47 | }, |
| 48 | Mapsrust-analyzer cargo schemars 1.2.2 map/Maps# { |
| 49 | // It's unfortunate that this adds an unused `IndirectU32` to the schema's `$defs`, |
| 50 | // but it's ultimately harmless. |
| 51 | enum_maprust-analyzer cargo schemars 1.2.2 map/Maps#enum_map.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::from_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][`FromIterator<(K, V)>`]from_iter().([( |
| 52 | Enumrust-analyzer cargo schemars 1.2.2 map/Enum#::UntaggedIndirectU32rust-analyzer cargo schemars 1.2.2 map/Enum#UntaggedIndirectU32#(IndirectU32rust-analyzer cargo schemars 1.2.2 map/IndirectU32#(1000000)), |
| 53 | true, |
| 54 | )]), |
| 55 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo schemars 1.2.2 map/impl#[Maps][Default]default().() |
| 56 | }, |
| 57 | ], |
| 58 | ) |
| 59 | .assert_matches_de_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_matches_de_roundtrip().(arbitrary_valuesrust-analyzer cargo schemars 1.2.2 test_helper/arbitrary_values().()); |
| 60 | } |