Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: expand glob imports #1152

Merged
merged 14 commits into from
May 29, 2024
Merged

refactor: expand glob imports #1152

merged 14 commits into from
May 29, 2024

Conversation

joshka
Copy link
Member

@joshka joshka commented May 28, 2024

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 #1150 for more details.

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.) in all the
examples.

See #1150 for more details.
examples/demo/ui.rs Outdated Show resolved Hide resolved
examples/colors_rgb.rs Outdated Show resolved Hide resolved
examples/constraint-explorer.rs Outdated Show resolved Hide resolved
examples/demo2/main.rs Outdated Show resolved Hide resolved
examples/demo2/tabs/weather.rs Outdated Show resolved Hide resolved
@joshka joshka requested a review from EdJoPaTo May 28, 2024 20:22
@EdJoPaTo
Copy link
Contributor

EdJoPaTo commented May 28, 2024

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
Copy link
Member Author

joshka commented May 28, 2024

wildcard_imports = "allow"

b82ccc2

@joshka joshka changed the title docs(examples): expand all glob imports chore: expand all glob imports May 28, 2024
Cargo.toml Outdated Show resolved Hide resolved
@joshka joshka requested a review from EdJoPaTo May 29, 2024 10:12
Copy link
Contributor

@EdJoPaTo EdJoPaTo left a comment

Choose a reason for hiding this comment

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

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? 🤔

@joshka joshka changed the title chore: expand all glob imports refactor: expand glob imports May 29, 2024
@joshka
Copy link
Member Author

joshka commented May 29, 2024

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

@joshka joshka merged commit 8061813 into main May 29, 2024
33 checks passed
@joshka joshka deleted the jm/remove-prelude-examples branch May 29, 2024 11:42
itsjunetime pushed a commit to itsjunetime/ratatui that referenced this pull request Jun 23, 2024
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 ratatui#1150 for more details.
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