#index-map

no-std indexmap-nostd

A no_std compatible implementation of the indexmap crate

4 releases (breaking)

0.4.0 Aug 25, 2022
0.3.0 Aug 25, 2022
0.2.0 Aug 25, 2022
0.1.0 Aug 24, 2022

#1415 in Data structures

Download history 57489/week @ 2024-06-14 61784/week @ 2024-06-21 51143/week @ 2024-06-28 50713/week @ 2024-07-05 66912/week @ 2024-07-12 66561/week @ 2024-07-19 67832/week @ 2024-07-26 65342/week @ 2024-08-02 78440/week @ 2024-08-09 69305/week @ 2024-08-16 69103/week @ 2024-08-23 77391/week @ 2024-08-30 79339/week @ 2024-09-06 77445/week @ 2024-09-13 73444/week @ 2024-09-20 56670/week @ 2024-09-27

301,700 downloads per month
Used in 207 crates (2 directly)

Apache-2.0

47KB
1K SLoC

indexmap-nostd

A no_std compatible indexmap crate (re)implementation.

Note: The indexmap crate already supports to be compiled in no_std environments and it uses hashbrown crate's HashMap under the hood which still requires some sort of randomized initialization. However, some embedded platforms simply cannot provide ways to randomly seed hash maps and similar data structures making code that depends on it susceptible to users (or attackers) that control inputs to those hash maps.

Therefore indexmap-nostd is a (re)implementation of the indexmap crate that replaces the internal use of HashMap with BTreeMap.

Advantages

This crate and its data structures can be used in any embedded no_std environment without the need to provide random seeds for HashMap initialization.

Disadvantages

  • The current implementation of indexmap-nostd focuses on being easy to maintain simple code which trades off efficiency compared to the original indexmap crate. An example of performance regression is that now inserted keys are duplicated.
  • Due to the above point some methods now require additional where bounds. For example IndexMap::insert now requires K: Clone.
  • We are primarily interested in getting this no_std compatible implementation to be working for the wasmparser crate. This means that we primarily provide a subset of the features and API of the original indexmap crate and might not be interested in adding features that we do not need for this use case that are also hard to implement or maintain.

Dependencies

~170KB