#chaining #mutable #modifiers #api #user #modification #fluid

modifier

Fluid chaining APIs for both mutable ownership types

10 releases

Uses old Rust 2015

0.1.0 Apr 3, 2015
0.0.9 Jan 29, 2015
0.0.5 Dec 27, 2014
0.0.3 Nov 28, 2014

#2178 in Rust patterns

Download history 10302/week @ 2024-05-04 10968/week @ 2024-05-11 9082/week @ 2024-05-18 8690/week @ 2024-05-25 10510/week @ 2024-06-01 9613/week @ 2024-06-08 11143/week @ 2024-06-15 8569/week @ 2024-06-22 10380/week @ 2024-06-29 11358/week @ 2024-07-06 11020/week @ 2024-07-13 9200/week @ 2024-07-20 9025/week @ 2024-07-27 10692/week @ 2024-08-03 11209/week @ 2024-08-10 8573/week @ 2024-08-17

40,734 downloads per month
Used in 196 crates (12 directly)

MIT license

5KB
112 lines

Rust-Modifier

Chaining APIs for both self -> Self and &mut self methods.

Example

let mut thing = Thing { x: 6 };
thing.set_mut(ModifyX(8));
assert_eq!(thing.x, 8);

let thing = thing.set(ModifyX(9));
assert_eq!(thing.x, 9);

Overview

Rust-modifier allows you to define modifiers just once, then use them through both set and set_mut, allowing downstream users the ability to use whichever API is most convenient.

Additionally, rust-modifier allows users to define their own modifiers, arbitrarily extending the utility of existing types.

LICENSE

MIT


lib.rs:

Overloadable modification through both owned and mutable references to a type with minimal code duplication.

No runtime deps