src/: core crate code.context/handles task context and task-local utilities;task/owns spawn/config/types;sys/provides platform-specific shims for stdlib vs wasm;*_executor.rsfiles expose global/current/thread executors;dyn_*files cover object-safe adapters.tests/: integration tests (e.g.,tests/static_brute.rs,tests/executor_yield_test.rs). Use thetest_executorsdev dependency for harnesses.examples/: runnable snippets showing API usage.art/: branding assets; not needed for builds.Cargo.toml: crate metadata (edition 2024) and target-specific deps, especially for wasm.
cargo check/cargo build: fast compile check or full build for the current target.cargo testorcargo test -- --nocapture: run host tests; the latter surfaces logging.CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER="wasm-bindgen-test-runner" cargo +nightly test --target wasm32-unknown-unknown: run wasm tests in a browser runner.CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER="wasm-bindgen-test-runner" RUSTFLAGS='-C target-feature=+atomics,+bulk-memory,+mutable-globals' cargo +nightly test --target wasm32-unknown-unknown -Z build-std=std,panic_abort: wasm tests with atomics.cargo fmt/cargo fmt -- --check: format or verify formatting.cargo clippy --all-targets --all-features: lint; address warnings or justify deviations.
- Rust 2024 edition with
rustfmtdefaults (4-space indent, trailing commas encouraged). Runcargo fmtbefore sending patches. - Prefer
snake_casefor modules/functions,CamelCasefor types/traits,SCREAMING_SNAKE_CASEfor constants. Task-local identifiers match existing names (e.g.,TASK_ID,TASK_PRIORITY). - Keep APIs object-safe where required and reuse existing type aliases for erased futures/observers to avoid type bloat.
- Document behavior with
///doc comments, focusing on invariants and executor semantics rather than restating signatures.
- Host tests use standard
#[test]plus conditional wasm attributes; integration suites live intests/. Name new tests after behavior (*_yields,*_cancels) for clarity. - Use
test_executorshelpers for lightweight executor instances in unit/integration tests. - For wasm, ensure
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser)is present when adding new suites; keep async tests non-blocking. - No formal coverage gate, but add focused tests when changing spawn semantics, task locals, or cancellation flows.
- Commit messages: short, imperative, and scoped (e.g.,
Tighten poll scheduling,Document wasm runner). Include rationale when touching executor semantics or public traits. - Before opening a PR: run
cargo fmt,cargo clippy --all-targets, and the relevantcargo test(host and wasm when applicable). Note any skipped targets and why. - PR description should link related issues, summarize behavior changes, and call out API/semver impacts. Include logs or screenshots only if modifying documentation assets.
- wasm32 is a first-class target; use the
sys/wasm.rsimplementations and avoid threading APIs unavailable on wasm. - When adding timeouts or sleeps, prefer existing abstractions in
systo stay compatible withwasm_safe_threadandweb-time.