2 releases
0.0.2 | Jun 2, 2024 |
---|---|
0.0.1 | Jun 2, 2024 |
#1019 in Rust patterns
Used in 3 crates
(2 directly)
6KB
74 lines
scopefn
scopefn
is a Rust crate that provides scope functions which inspired by Kotlin's scope functions. It allows you to write more concise and expressive code by providing a set of functions that operate on a value within a specific scope.
Example Usage
Debugging
fn with_debug(data: Vec<i32>) -> Vec<i32> {
data
.apply(|d| debug!(d))
.do_what_you_want()
.apply(|d| debug!(d))
}
Sorting
fn sort_them(data: Vec<i32>) -> Vec<i32> {
data.apply_mut(|d| d.sort())
}
Dependencies
~12KB