Loading...
Loading...
Compare original and translation side by side
no_stdno_std| Tool | Purpose |
|---|---|
| Build, dep management, script runner |
| Lint ( |
| Formatter ( |
| Test runner |
| License + advisory + duplicate-dep checks |
| Find unused dependencies |
rust-toolchain.tomlcargo update -p <crate>cargo updateCargo.lock| 工具 | 用途 |
|---|---|
| 构建、依赖管理、脚本运行器 |
| 代码检查( |
| 代码格式化( |
| 测试运行器 |
| 许可证、安全预警、重复依赖检查 |
| 查找未使用的依赖 |
rust-toolchain.tomlcargo update -p <crate>cargo updateCargo.lockCargo.toml # [workspace] members + [workspace.dependencies]
crates/
protocol/ # Shared types, no deps on other workspace crates
storage/ # Persistence, depends on protocol
service/ # Business logic, depends on protocol + storage
cli/ # Binary, depends on everything[workspace.dependencies]foo = { workspace = true }protocollib.rs//!pub usepubpubpub usepub(crate)pub useE0364pub(crate) usecargo semver-checksmacro_rules!$crate$x:expr$t:ttsyn::ErrorPathOsStr///# Examples# Errors# Panics# Safety//!cargo test --doc#![deny(missing_docs)]device = "gpu"[workspace.lints.*]#![deny(...)][workspace.lints.clippy]
all = { level = "warn", priority = -1 }
pedantic = { level = "warn", priority = -1 }[lints] workspace = trueCargo.toml # [workspace]成员 + [workspace.dependencies]
crates/
protocol/ # 共享类型,不依赖工作区中的其他crate
storage/ # 持久化模块,依赖protocol
service/ # 业务逻辑,依赖protocol + storage
cli/ # 二进制程序,依赖所有模块[workspace.dependencies]foo = { workspace = true }protocollib.rs//!pub usepubpubpub usepub(crate)pub useE0364pub(crate) usecargo semver-checksmacro_rules!$crate$x:expr$t:ttsyn::ErrorPathOsStr///# Examples# Errors# Panics# Safety//!cargo test --doc#![deny(missing_docs)]device = "gpu"[workspace.lints.*]#![deny(...)][workspace.lints.clippy]
all = { level = "warn", priority = -1 }
pedantic = { level = "warn", priority = -1 }[lints] workspace = truetarget-cpu=nativetarget-cpu=nativethiserroranyhow::Result.context("what was being attempted")Box<dyn Error>?.unwrap().expect()mainexpect("...")#[from].map_err(MyError::from)bail!("...")ensure!(cond, "...")Result<T, E>#[must_use]Resultlet _ = validate(x);Client<Uninitialized>Client<Connected>thiserroranyhow::Result.context("当前操作描述")Box<dyn Error>?main.unwrap().expect()expect("...")#[from].map_err(MyError::from)bail!("...")ensure!(cond, "...")Result<T, E>#[must_use]Resultlet _ = validate(x);Client<Uninitialized>Client<Connected>&str&String&[T]&Vec<T>StringVec<T>Arc<T>Rc<T>Cow<'_, str>'aBytes&str&String&[T]&Vec<T>StringVec<T>Arc<T>Rc<T>Cow<'_, str>'aBytes#[tokio::main]features = ["full"]features = ["rt", "macros", "sync"]tokio::spawnJoinSettokio::select!tokio::task::spawn_blockingtokio::sync::Mutex.awaitstd::sync::Mutextokio::sync::RwLockMutexarc-swap::ArcSwapCancellationTokentokio-utilmpscSemaphorelet _permit = sem.acquire().await?;Arc<Semaphore>tokioasync-stdsmol#[tokio::main]features = ["full"]features = ["rt", "macros", "sync"]tokio::spawnJoinSettokio::select!tokio::task::spawn_blocking.awaittokio::sync::Mutexstd::sync::Mutextokio::sync::RwLockMutexarc-swap::ArcSwapCancellationTokentokio-utilmpscSemaphorelet _permit = sem.acquire().await?;Arc<Semaphore>tokioasync-stdsmol#[derive(Parser)]#[derive(Subcommand)]enum Commands#[command(flatten)] struct CommonArgs--jsonserde_json::to_string(&value)?main--help--version#[command(version)]#[derive(Parser)]#[derive(Subcommand)]enum Commands#[command(flatten)] struct CommonArgs--jsonserde_json::to_string(&value)?main--help#[command(version)]--versionactix-webResult<impl IntoResponse, AppError>IntoResponseAppErroraxum::extract::Json<T>T: Deserialize + ValidatevalidatorState<Arc<AppState>>lazy_statictower::ServiceBuilderLoadShedConcurrencyLimitactix-webResult<impl IntoResponse, AppError>AppErrorIntoResponseaxum::extract::Json<T>T: Deserialize + ValidatevalidatorState<Arc<AppState>>lazy_statictower::ServiceBuilderLoadShedConcurrencyLimit| Workload | Approach |
|---|---|
| Independent async I/O | |
| Data-parallel CPU work | |
| Shared mutable state across threads | |
| Single-producer pipelines | |
| Broadcast / fan-out | |
rayontokiotokio::task::spawn_blocking.block_on()| 工作负载 | 实现方式 |
|---|---|
| 独立异步I/O | |
| 数据并行CPU工作 | |
| 线程间共享可变状态 | |
| 单生产者流水线 | |
| 广播/扇出 | |
rayontokiotokio::task::spawn_blocking.block_on()#[test]cargo nextest run --workspacecargo testmod tests { ... }tests/#[tokio::test]flavor = "multi_thread"rstestproptestquickcheckinstacargo insta reviewassert_cmdpredicatesmatches!assert!(matches!(result.unwrap_err(), MyError::Validation(_)))matchcargo llvm-cov --workspace --htmlcargo fuzzlibfuzzer-sysia-writing-tests#[test]cargo nextest run --workspacecargo testmod tests { ... }tests/#[tokio::test]flavor = "multi_thread"rstestproptestquickcheckinstacargo insta reviewassert_cmdpredicatesmatches!assert!(matches!(result.unwrap_err(), MyError::Validation(_)))cargo llvm-cov --workspace --htmlcargo fuzzlibfuzzer-sysia-writing-testsunsafe#[allow]#[expect]unsafe// SAFETY:unsafepub(crate)miricargo +nightly miri testunsafebytemuckzerocopybytesunsafemaingetenvOnceLockLD_LIBRARY_PATHunsafe#[allow]#[expect]unsafe// SAFETY:unsafepub(crate)unsafemiricargo +nightly miri testbytemuckzerocopybytesunsafemaingetenvOnceLockLD_LIBRARY_PATH/health/ready/health/readytracingtracing-subscriber#[instrument]println!log::tracingtracing-subscriber#[instrument]println!log::ia-infrastructure-engineerrustsec/audit-checkcargo-llvm-covSwatinem/rust-cachetaiki-e/install-actionia-infrastructure-engineerrustsec/audit-checkcargo-llvm-covSwatinem/rust-cachetaiki-e/install-action#[allow(clippy::...)]#[expect(clippy::lint_name, reason = "...")]expectallowexpect#[allow(clippy::...)]#[expect(clippy::lint_name, reason = "...")]expectallowexpectcargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run --workspacecargo test --workspacecargo deny checkunsafe// SAFETY:cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run --workspacecargo test --workspacecargo deny checkunsafe// SAFETY: