#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

#2230 in Rust patterns

Download history 3940/week @ 2023-11-26 4266/week @ 2023-12-03 5356/week @ 2023-12-10 5510/week @ 2023-12-17 3112/week @ 2023-12-24 5987/week @ 2023-12-31 6291/week @ 2024-01-07 4931/week @ 2024-01-14 6390/week @ 2024-01-21 5012/week @ 2024-01-28 4917/week @ 2024-02-04 5943/week @ 2024-02-11 5955/week @ 2024-02-18 7063/week @ 2024-02-25 11968/week @ 2024-03-03 2566/week @ 2024-03-10

28,321 downloads per month
Used in 203 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