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: ACK9ffa01f5ed
jamillambert: ACK9ffa01f5ed
apoelstra: ACK9ffa01f5ed
Tree-SHA512: 646944d2d6957970e4e9f717e3853f62961c564af73186bb075aa70a21609fb378a650211b21bc08d14014e05a5be26c56e5532679692dc97dda53277137e45c
This commit is contained in:
commit
c03e23b004
|
@ -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`
|
||||
|
|
Loading…
Reference in New Issue