bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.41k stars 3.59k forks source link

Using `trait as _` to avoid namespace pollution #16268

Open BenjaminBrienen opened 2 weeks ago

BenjaminBrienen commented 2 weeks ago

This is really interesting, I hadn't considered using trait as _ to avoid name collisions. At a glance this also works in preludes. For a future PR, could be nice to do this for extension style traits (e.g., AppAssetExt etc.) so the preludes aren't so heavy with names.

_Originally posted by @bushrat011899 in https://github.com/bevyengine/bevy/pull/16163#discussion_r1821705357_

benfrankel commented 2 weeks ago

This is a duplicate of https://github.com/bevyengine/bevy/issues/13959 btw :)

Although this issue does seem to go further and say that use trait as _ should be preferred even if it's not being re-exported (not just pub use trait as _). I'd personally agree with that as well, although that's more of a question of style.