ratatui-org / ratatui

Rust library that's all about cooking up terminal user interfaces (TUIs) 👨‍🍳🐀
https://ratatui.rs
MIT License
8.86k stars 269 forks source link

refactor: expand glob imports #1152

Closed joshka closed 1 month ago

joshka commented 1 month ago

Consensus is that explicit imports make it easier to understand the example code. This commit removes the prelude import from all examples and replaces it with the necessary imports, and expands other glob imports (widget::, Constraint::, KeyCode::*, etc.) everywhere else. Prelude glob imports not in examples are not covered by this PR.

See https://github.com/ratatui-org/ratatui/issues/1150 for more details.

EdJoPaTo commented 1 month ago

Given that there are 4 warnings remaining when enabling (= removing the allow) of wildcard_imports (one in the examples), should it just be enabled in this PR too?

https://github.com/ratatui-org/ratatui/blob/74a32afbaef8851f9462b27094d88d518e56addf/Cargo.toml#L77

Edit: 5 including https://github.com/ratatui-org/ratatui/blob/74a32afbaef8851f9462b27094d88d518e56addf/src/widgets/scrollbar.rs#L7

joshka commented 1 month ago

wildcard_imports = "allow"

b82ccc28e

joshka commented 1 month ago

This helps a lot with reading code without an IDE ✨

Maybe remove the "all" from the title as prelude::* is still used in the lib itself. Also, this is a "refactor:" as it adapts the source code while maintaining the behavior? 🤔

done and done. Also fixed a doc lint