macro_rules! builder_setter {
($field:ident, $type:ty, $doc:expr) => { ... };
}Expand description
Generates a scalar field setter method.
Creates a setter method that takes ownership of self, sets a field to Some(value),
and returns self for method chaining.
§Arguments
$field- The field name$type- The field type$doc- Documentation string for the setter
§Examples
ⓘ
impl MessageBuilder {
builder_setter!(id, u32, "Sets the CAN message ID");
}
// Expands to:
// /// Sets the CAN message ID
// #[must_use = "builder method returns modified builder"]
// pub fn id(mut self, id: u32) -> Self {
// self.id = Some(id);
// self
// }