bevy/crates/bevy_platform_support/Cargo.toml
krunchington e5158ed96c
Update docs to explain default Hasher issue (#18350)
# Objective

I experienced an issue where `HashMap::new` was not returning a value
typed appropriately for a `HashMap<K,V>` declaration that omitted the
Hasher- e.g. the Default Hasher for the type is different than what the
`new` method produces.

After discussion on discord, this appears to be an issue in `hashbrown`,
and working around it would be very nontrivial, requiring a newtype on
top of the `hashbrown` implementation. Rather than doing that, it was
suggested that we add docs to make the issue more visible and provide a
clear workaround.

## Solution

Updated the docs for `bevy_platform_support::collections`. I couldn't
update Struct docs because they're re-exports, so I had to settle for
the module.

Note that the `[HashMap::new]` link wasn't generating properly- I'm not
sure why. I see the method in the docs.rs site,
https://docs.rs/hashbrown/0.15.1/hashbrown/struct.HashMap.html#method.new,
but not on the generated internal documentation. I wonder if `hashbrown`
isn't actually implementing the new or something?

## Testing

n/a although I did generate and open the docs on my Ubuntu machine.

---

## Showcase

before:

![image](https://github.com/user-attachments/assets/5c80417d-9c4e-4b57-825f-911203ed8558)

after:

![image](https://github.com/user-attachments/assets/420f6775-2f32-466f-a580-bb1344016bda)

---------

Co-authored-by: Zachary Harrold <zac@harrold.com.au>
2025-03-17 23:25:52 +00:00

87 lines
2.5 KiB
TOML

[package]
name = "bevy_platform_support"
version = "0.16.0-dev"
edition = "2024"
description = "Platform compatibility support for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"
license = "MIT OR Apache-2.0"
keywords = ["bevy"]
[features]
default = ["std"]
# Functionality
## Adds serialization support through `serde`.
serialize = ["hashbrown/serde"]
# Platform Compatibility
## Allows access to the `std` crate. Enabling this feature will prevent compilation
## on `no_std` targets, but provides access to certain additional features on
## supported platforms.
std = [
"alloc",
"critical-section?/std",
"portable-atomic/std",
"portable-atomic-util/std",
"spin/std",
"foldhash/std",
]
## Allows access to the `alloc` crate.
alloc = ["portable-atomic-util/alloc", "dep:hashbrown"]
## `critical-section` provides the building blocks for synchronization primitives
## on all platforms, including `no_std`.
critical-section = ["dep:critical-section", "portable-atomic/critical-section"]
## Enables use of browser APIs.
## Note this is currently only applicable on `wasm32` architectures.
web = ["dep:web-time", "dep:getrandom"]
[dependencies]
cfg-if = "1.0.0"
critical-section = { version = "1.2.0", default-features = false, optional = true }
spin = { version = "0.9.8", default-features = false, features = [
"mutex",
"spin_mutex",
"rwlock",
"once",
"lazy",
"barrier",
] }
foldhash = { version = "0.1.3", default-features = false }
hashbrown = { version = "0.15.1", features = [
"equivalent",
"raw-entry",
], optional = true, default-features = false }
[dev-dependencies]
bevy_ecs = { path = "../bevy_ecs", version = "0.16.0-dev" }
[target.'cfg(target_arch = "wasm32")'.dependencies]
web-time = { version = "1.1", default-features = false, optional = true }
getrandom = { version = "0.2.0", default-features = false, optional = true, features = [
"js",
] }
[target.'cfg(not(all(target_has_atomic = "8", target_has_atomic = "16", target_has_atomic = "32", target_has_atomic = "64", target_has_atomic = "ptr")))'.dependencies]
portable-atomic = { version = "1", default-features = false, features = [
"fallback",
] }
spin = { version = "0.9.8", default-features = false, features = [
"portable_atomic",
] }
[target.'cfg(not(target_has_atomic = "ptr"))'.dependencies]
portable-atomic-util = { version = "0.2.4", default-features = false }
[lints]
workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true