Skip to main content

operator

Attribute Macro operator 

Source
#[operator]
Expand description

Optional sugar adding a ready-made astrs_operator_api::OperatorRegistry entry to an astrs_operator_api::Operator impl (blueprint §9.3).

ⓘ
// `ignore`d: exercising this for real needs `astrs-operator-api` as a
// dependency, and this crate cannot add one — `astrs-operator-api`
// already depends on `astrs-operator-macros` for the derive above, so
// the reverse dependency would be circular. The real, compiled,
// end-to-end exercise of this macro lives in `astrs-operator-api`'s own
// test suite instead, where both crates are legitimately available;
// this crate's own tests check the expansion at the token level (see
// `operator_attr`'s `#[cfg(test)]` module).
use astrs_operator_macros::operator;

#[operator]
#[derive(Default)]
struct Crop;

gives Crop an inherent operator_entry() returning (&'static str, astrs_operator_api::OperatorConstructor) — the same shape astrs_operator_api::register_operator!(Crop) produces, so either can feed OperatorRegistry::from_entries. See the operator_attr module docs for the default name it picks and how to override it.