Skip to content

Feat: Added external IndexMap and IndexSet types#149

Closed
adpthegreat wants to merge 1 commit intoanza-xyz:masterfrom
adpthegreat:add_indexmap_external_type
Closed

Feat: Added external IndexMap and IndexSet types#149
adpthegreat wants to merge 1 commit intoanza-xyz:masterfrom
adpthegreat:add_indexmap_external_type

Conversation

@adpthegreat
Copy link
Copy Markdown
Contributor

@adpthegreat adpthegreat commented Feb 4, 2026

This PR adds external types IndexMap and IndexSet from the IndexMap crate gated behind the indexmap feature flag with appropriate tests, it is heavily based on the impl_seq macro which is the macro to implement sequential types

Will add more tests to test serialization and deserialization with different ordering

@madmaxio
Copy link
Copy Markdown

Hello, any plans to merge this?

@adpthegreat
Copy link
Copy Markdown
Contributor Author

have to rebase and tag a maintainer brb

thiserror = { version = "2.0.16", default-features = false }
wincode-derive = { version = "0.3.1", path = "../wincode-derive", optional = true }
uuid = { version = "1.20.0", optional = true, default-features = false }
indexmap = { version = "2.13.0", features = ["arbitrary", "serde" ], optional = true }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't require arbitrary and serde in the [dependencies] section. If features are needed for tests, they should be included in [dev-dependencies] specifically.

It also doesn't appear that the arbitrary feature is used.

thiserror = { version = "2.0.16", default-features = false }
wincode-derive = { version = "0.3.1", path = "../wincode-derive", optional = true }
uuid = { version = "1.20.0", optional = true, default-features = false }
indexmap = { version = "2.13.0", features = ["arbitrary", "serde" ], optional = true }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, IndexMap works without std, so we should accommodate that as well.

};

#[cfg(feature = "indexmap")]
unsafe impl<C: Config, K, V> SchemaWrite<C> for IndexMap<K, V>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should make this generic over a BuildHasher, like the HashMap implementation.

}

#[cfg(feature = "indexmap")]
unsafe impl<'de, C: Config, K, V> SchemaRead<'de, C> for IndexMap<K, V>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should make this generic over a BuildHasher, like the HashMap implementation.

}

#[cfg(feature = "indexmap")]
unsafe impl<C: Config, K> SchemaWrite<C> for IndexSet<K>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should make this generic over a BuildHasher, like the HashSet implementation.

}

#[cfg(feature = "indexmap")]
unsafe impl<'de, C: Config, K> SchemaRead<'de, C> for IndexSet<K>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should make this generic over a BuildHasher, like the HashSet implementation.

+ (key_size + value_size) * len;
// SAFETY: `K::TYPE_META` and `V::TYPE_META` specify static sizes, so `len` writes of `(K::Src, V::Src)`
// and `<BincodeLen>::write` will write `needed` bytes, fully initializing the trusted window.
let writer = &mut unsafe { writer.as_trusted_for(needed) }?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should avoid using &mut on writers and prefer by_ref.

See #177

) = (K::TYPE_META, V::TYPE_META)
{
let reader =
&mut unsafe { reader.as_trusted_for((key_size + value_size) * len) }?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should avoid using &mut on readers and prefer by_ref.

See #177

// SAFETY: `K::TYPE_META` specifies a static size, so `len` reads of `T::Dst`
// will consume `size * len` bytes, fully consuming the trusted window.
let reader =
&mut unsafe { reader.as_trusted_for(size * len) }?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should avoid using &mut on readers and prefer by_ref.

See #177

@cpubot
Copy link
Copy Markdown
Contributor

cpubot commented Mar 20, 2026

Closing for inactivity

@cpubot cpubot closed this Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants