mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-15 00:41:01 +03:00
one use per crate, and write the rule down
`fs.rs` came out of the move with two ungated `use hbb_common::` statements,
because the original single `use crate::{...}` had to give up `message_proto`
to the new crate and the rest was left in a second block. Fold it back into one.
A scan of the whole tree for the same shape finds nothing else: every other file
with more than one top-level `use base::` or `use hbb_common::` is split by a
`#[cfg]` that does not cover the whole block, or by `pub use` next to `use`.
Those are the cases that cannot merge, so AGENTS.md now states both the rule and
the exemption.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab
This commit is contained in:
28
AGENTS.md
28
AGENTS.md
@@ -67,6 +67,34 @@ workspace member. `base::config::keys` re-exports the handful of keys
|
|||||||
* Do not make formatting-only changes.
|
* Do not make formatting-only changes.
|
||||||
* Keep naming/style consistent with nearby code.
|
* Keep naming/style consistent with nearby code.
|
||||||
|
|
||||||
|
### Imports
|
||||||
|
|
||||||
|
* One `use` per crate. Everything a file takes from the same crate goes in a
|
||||||
|
single braced block, not one statement per item:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
// no
|
||||||
|
use base::fs;
|
||||||
|
use base::message_proto::*;
|
||||||
|
|
||||||
|
// yes
|
||||||
|
use base::{fs, message_proto::*};
|
||||||
|
```
|
||||||
|
|
||||||
|
* The only reason to split is a `#[cfg(...)]` that does not apply to the whole
|
||||||
|
block -- an attribute binds to one item, so a differently-gated import has to
|
||||||
|
stand on its own. A `pub use` re-export likewise cannot join a plain `use`.
|
||||||
|
|
||||||
|
```rust
|
||||||
|
#[cfg(not(feature = "flutter"))]
|
||||||
|
use base::fs;
|
||||||
|
use base::message_proto::*;
|
||||||
|
```
|
||||||
|
|
||||||
|
* When splitting an existing `use` because some of its items moved to another
|
||||||
|
crate, fold each side into that crate's existing block rather than leaving a
|
||||||
|
second statement behind.
|
||||||
|
|
||||||
### Comments
|
### Comments
|
||||||
|
|
||||||
* Avoid comments unless they explain a non-obvious reason, constraint, or workaround.
|
* Avoid comments unless they explain a non-obvious reason, constraint, or workaround.
|
||||||
|
|||||||
@@ -16,11 +16,13 @@ use tokio::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::message_proto::*;
|
use crate::message_proto::*;
|
||||||
use hbb_common::{anyhow::anyhow, bail, get_version_number, ResultType, Stream};
|
|
||||||
// https://doc.rust-lang.org/std/os/windows/fs/trait.MetadataExt.html
|
// https://doc.rust-lang.org/std/os/windows/fs/trait.MetadataExt.html
|
||||||
use hbb_common::{
|
use hbb_common::{
|
||||||
|
anyhow::anyhow,
|
||||||
|
bail,
|
||||||
compress::{compress, decompress},
|
compress::{compress, decompress},
|
||||||
config::Config,
|
config::Config,
|
||||||
|
get_version_number, ResultType, Stream,
|
||||||
};
|
};
|
||||||
|
|
||||||
static NEXT_JOB_ID: AtomicI32 = AtomicI32::new(1);
|
static NEXT_JOB_ID: AtomicI32 = AtomicI32::new(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user