DioxusLabs / DioxusLabs/dioxus
#[cfg(platform)] for Feature Flags
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
## Feature Request
Dioxus runs on many platforms and OS, and I'm sure with different versions of the same Operating Systems or in case of the web then multiple Browsers / Renderers, this creates alot of confusion when one has to chase `caniuse.com` for Web and other vendor specific docs to handle for specific OS
## Implement Suggestion
Dixous can take this a bit further for help with DX.
We can easily have multiple platforms: "web", "blitz", "native", "desktop", "mobile", "xr" and so forth (similar to `#[cfg(feature = "")]`)
Example API:
Web Browser / User Agent: `#[cfg(platform = "web", browser = "")]`
iOS: `#[cfg(platform = "mobile", os = "ios", min_version = "18.3")]`
iPadOS: `#[cfg(platform = "tablet", os = "ipados")]`
Desktop (i.e. Windows 8 to 11): `#[cfg(platform = "desktop", os = "windows", min_version = "8", max_version = "10")]`
Creating fine-grained cfg handling for platform specific features, we could also make the second and any consecutive attributes optional.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.