Merge rust-bitcoin/rust-bitcoin#2894: Contributing: add instructions on wildcards in import statements

9ffa01f5ed Contributing: add instructions on wildcards in import statements (Jose Storopoli)

Pull request description:

  Clarifies the wildcard policy in `Contributing.md`.

  Relates to #2875.

ACKs for top commit:
  tcharding:
    ACK 9ffa01f5ed
  jamillambert:
    ACK 9ffa01f5ed
  apoelstra:
    ACK 9ffa01f5ed

Tree-SHA512: 646944d2d6957970e4e9f717e3853f62961c564af73186bb075aa70a21609fb378a650211b21bc08d14014e05a5be26c56e5532679692dc97dda53277137e45c
This commit is contained in:
Andrew Poelstra 2024-06-23 14:29:07 +00:00
commit c03e23b004
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 18 additions and 1 deletions

View File

@ -221,7 +221,6 @@ We use the following style for import statements, see
(https://github.com/rust-bitcoin/rust-bitcoin/discussions/2088) for the discussion that led to this.
```rust
// Modules first, as they are part of the project's structure.
pub mod aa_this;
mod bb_private;
@ -237,6 +236,24 @@ pub use {
crate::aa_aa_this,
crate::bb_bb::That,
}
// Avoid wildcard imports, except for 3 rules:
// Rule 1 - test modules.
#[cfg(test)]
mod tests {
use super::*; // OK
}
// Rule 2 - enum variants.
use LockTime::*; // OK
// Rule 3 - opcodes.
use opcodes::all::*; // OK
// Finally here is an example where we don't allow wildcard imports:
use crate::prelude::*; // *NOT* OK
use crate::prelude::{DisplayHex, String, Vec} // OK
```
#### Return `Self`