#[derive(WritableKeypaths)]Expand description
Derives only writable keypath methods for struct fields.
This macro is a convenience wrapper that generates only writable keypaths,
equivalent to using #[derive(Kp)] with #[Writable] on the struct.
§Generated Methods
For each field field_name, generates:
field_name_w()- Returns aWritableKeyPath<Struct, FieldType>for non-optional fieldsfield_name_fw()- Returns aWritableOptionalKeyPath<Struct, InnerType>for optional/container fieldsfield_name_fw_at(index)- Returns aWritableOptionalKeyPathfor indexed mutable access
§Examples
ⓘ
use keypaths_proc::WritableKeypaths;
#[derive(WritableKeypaths)]
struct Counter {
value: u32,
history: Vec<u32>,
}
// Usage:
let mut counter = Counter { value: 0, history: vec![] };
let value_path = Counter::value_w();
*value_path.get_mut(&mut counter) += 1;