Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 tasks
jonasbb opened this issue Nov 16, 2022 · 0 comments · Fixed by #531
Closed
3 tasks

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

jonasbb opened this issue Nov 16, 2022 · 0 comments · Fixed by #531
Labels
bug Something isn't working documentation Improvements or additions to documentation no_std Issues relating to the `no_std` usage of this crate.

Comments

@jonasbb
Copy link
Owner

jonasbb commented Nov 16, 2022

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?
@jonasbb jonasbb added bug Something isn't working documentation Improvements or additions to documentation no_std Issues relating to the `no_std` usage of this crate. labels Nov 16, 2022
@bors bors bot closed this as completed in c7361ef Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation no_std Issues relating to the `no_std` usage of this crate.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant