distributed_slice

Attribute Macro distributed_slice 

#[distributed_slice]
Expand description

linkme::distributed_slice re-exported as part of ktstr’s public surface. Combined with crate::linkme for the #[linkme(crate = ...)] annotation, this lets a downstream crate register entries into KTSTR_TESTS or KTSTR_SCHEDULERS without adding linkme as a direct Cargo dependency:

use ktstr::prelude::*;

fn my_test_fn(_ctx: &Ctx) -> Result<AssertResult> {
    Ok(AssertResult::pass())
}

#[distributed_slice(KTSTR_TESTS)]
#[linkme(crate = ktstr::linkme)]
static MY_ENTRY: KtstrTestEntry = KtstrTestEntry {
    name: "my_test",
    func: my_test_fn,
    ..KtstrTestEntry::DEFAULT
};

The #[linkme(crate = ...)] annotation is REQUIRED because the linkme proc-macro expansion hardcodes ::linkme::DistributedSlice — without the annotation, downstream crates without linkme in their Cargo.toml get an unresolved-import error. The annotation tells the macro to resolve type references through ktstr::linkme instead, which IS reachable from downstream by transitive dependency.

Downstream crates that already depend on linkme = "0.3" directly can omit the annotation. The #[ktstr_test] proc macro emits both attributes internally so test authors using the standard macro surface never have to spell either out.