Substitute BTreeMap/BTreeSet generated types for Vec (#459)

* Substitute BTreeMap/BTreeSet for Vec

* regen code

* cargo fmt

* undo test tweak since not substituting bounded things at the mo

* add a couple of comments
This commit is contained in:
James Wilson
2022-02-21 14:18:09 +00:00
committed by GitHub
parent e866d744de
commit d01fdd70d2
3 changed files with 13 additions and 47 deletions
+6 -6
View File
@@ -147,12 +147,12 @@ impl RuntimeGenerator {
"frame_support::traits::misc::WrapperKeepOpaque",
parse_quote!(::subxt::WrapperKeepOpaque),
),
// We override this because it's used as a key in a BTreeMap, and so we
// need to implement some extra derives for it for that to compile.
(
"sp_npos_elections::ElectionScore",
parse_quote!(::subxt::ElectionScore),
),
// BTreeMap and BTreeSet impose an `Ord` constraint on their key types. This
// can cause an issue with generated code that doesn't impl `Ord` by default.
// Decoding them to Vec by default (KeyedVec is just an alias for Vec with
// suitable type params) avoids these issues.
("BTreeMap", parse_quote!(::subxt::KeyedVec)),
("BTreeSet", parse_quote!(::std::vec::Vec)),
]
.iter()
.map(|(path, substitute): &(&str, syn::TypePath)| {