Skip to content

Remove wildcard imports from source files - #14

Merged
shinaoka merged 1 commit into
tuwien-cms:mainlinefrom
sakuraba07:remove-wildcard-imports
Nov 22, 2025
Merged

Remove wildcard imports from source files#14
shinaoka merged 1 commit into
tuwien-cms:mainlinefrom
sakuraba07:remove-wildcard-imports

Conversation

@sakuraba07

Copy link
Copy Markdown
Contributor

Problem

The codebase uses wildcard imports (use module::*) extensively in production code, which makes it difficult to understand where symbols come from and can lead to name collisions. This was reported in #11.

The Rust language design team recommends using explicit imports for better code readability and maintainability, reserving wildcard imports only for preludes and test modules.

Solution

  • Replaced all wildcard imports in production code with explicit imports
  • Affected files:
    • src/roots.rs - explicit imports from arith module
    • src/round.rs - explicit imports from arith module
    • src/gauss.rs - explicit imports from arith and circular modules
    • src/circular.rs - explicit imports from arith, checks, funcs, and utils modules
    • src/exp.rs - explicit imports from multiple modules
    • src/hyperbolic.rs - explicit imports from arith, checks, exp, funcs, and roots modules
    • src/traits.rs - explicit imports from std::ops, num_traits, and simba::scalar
    • src/lib.rs - removed unused num_traits::Zero import
  • Test module wildcard imports (use super::*;) are intentionally kept as they are considered acceptable in Rust best practices

Testing

  • All 36 tests pass successfully
  • No functional changes to the code
  • Only import statements were modified

Impact

This change improves code readability by making it clear where each imported symbol comes from, making the codebase easier to understand and maintain.

Resolves #11

Replace wildcard imports (use module::*) with explicit imports
in the following files:
- src/roots.rs
- src/round.rs
- src/gauss.rs
- src/circular.rs
- src/exp.rs
- src/hyperbolic.rs
- src/traits.rs
- src/lib.rs (also remove unused import)

Test modules required minimal additional imports where functions
were previously available through wildcard imports but are now
explicitly imported only in production code.

Test module wildcard imports (use super::*) are intentionally
kept as they are considered acceptable in Rust best practices.

Resolves tuwien-cms#11
@shinaoka
shinaoka merged commit 0f3769d into tuwien-cms:mainline Nov 22, 2025
2 checks passed
@sakuraba07
sakuraba07 deleted the remove-wildcard-imports branch November 25, 2025 06:05
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.

Wildcard imports make the code unreadable

2 participants