Releases: udoprog/fixed-map
Releases · udoprog/fixed-map
0.9.4
0.9.0
Added
- Add stable
#[key(bitset)]
container attribute for bitset storage.
Changes
- Export the
Key
trait from the root of the crate, this means that users which previously used a key namedKey
might face issues (see below)
Migrating code which uses the local Key
name
This crate now exports the Key
trait from its root, if you're using a locally defined item named Key
and derive fixed_map::Key
you might now face issues.
The change is motivated because code which is generic over a Set
or a Map
would awkwardly have to import the trait separately from fixed_map::key::Key
instead of using the expected fixed_map::Key
, like this:
pub mod set {
use fixed_map::key::Key;
use fixed_map::Set;
use musli::de::{Decode, Decoder, SequenceDecoder};
use musli::en::{Encode, Encoder, SequenceEncoder};
use musli::mode::Mode;
pub fn encode<M, E, T>(set: &Set<T>, encoder: E) -> Result<E::Ok, E::Error>
where
M: Mode,
E: Encoder,
T: Key + Encode,
{
let mut seq = encoder.encode_sequence(set.len())?;
for value in set.iter() {
value.encode(seq.next()?)?;
}
seq.end()
}
}
The issue you're facing might be the following:
use fixed_map::{Key, Map};
#[derive(Debug, Clone, Copy, Key)]
enum Key {
First,
Second,
}
With this error:
error[E0255]: the name `Key` is defined multiple times
--> examples\basic.rs:4:1
|
1 | use fixed_map::{Key, Map};
| --- previous import of the trait `Key` here
...
4 | enum Key {
| ^^^^^^^^ `Key` redefined here
|
= note: `Key` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
The solution is to rename your local Key
.
use fixed_map::{Key, Map};
#[derive(Debug, Clone, Copy, Key)]
enum Numbers {
First,
Second,
}