scopefn

Crates.ioscopefn
lib.rsscopefn
version0.0.2
sourcesrc
created_at2024-06-02 06:19:21.44769
updated_at2024-06-02 07:08:16.426273
descriptionScope functions for Rust
homepage
repositoryhttps://github.com/lzt1008/scopefn
max_upload_size
id1259026
size9,079
(lzt1008)

documentation

README

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())
}
Commit count: 6

cargo fmt