Skip to content

Vec <-> BTreeMap conversion not available in no_std mode #527

@jonasbb

Description

@jonasbb

Someone on Discord pointed out that Seq <-> Map conversions don't work under no_std, given that the marker types Vec, BTreeMap, HashMap are only available with alloc/std.

#[cfg(feature = "alloc")]
tuple_seq_as_map_arr!([(K, V); N], BTreeMap<KAs, VAs>);
#[cfg(feature = "std")]
tuple_seq_as_map_arr!([(K, V); N], HashMap<KAs, VAs>);
  • Introduce Map and List/Seq types as replacements available in no_std.
  • Implement the required conversions.
    • The conversions might be able to use IntoIterator/FromIterator instead of hard-coding certain combinations. This could bring it closer to the older tuple_list_as_map behavior.
  • Update existing examples to slowly migrate to these new types.

Open questions:

  • Is List or Seq the better name? Serde uses seq.
  • Map might conflict with type aliases or import renames. But are there alternatives?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentationno_stdIssues relating to the `no_std` usage of this crate.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions