simple_scan

Crates.iosimple_scan
lib.rssimple_scan
version0.4.1
created_at2023-06-26 00:08:30.771358+00
updated_at2025-07-14 11:41:01.167673+00
descriptionIterator extensions for simple scan operation.
homepage
repositoryhttps://github.com/nossie531/simple_scan
max_upload_size
id899890
size26,147
(nossie531)

documentation

README

simple_scan

Iterator extensions for simple scan operation.

The author of this crate is not good at English.
Forgive me if the document is hard to read.

What is this?

This crate provides the IteratorSimpleScanExt trait. The IteratorSimpleScanExt trait is an extension trait of the Iterator trait, which implements some methods similar to the scan methods of the Iterator trait, but more simplified and specialized.

The following is a list of those methods. The sample code on the left shows the case where those simplified methods are used, and the sample code on the right shows the case where the same process is implemented with scan method.

Name example / equivalent code
trace
(0..10).trace(0, |s, x| s + x)
(0..10).scan(0, |s, x| {
    *s += x;
    Some(*s)
});
trace2
(0..10).trace2(0, |s, x| s + x)
(0..10).scan(0, |s, x| {
    let prev = *s;
    *s += x;
    Some((prev, *s))
});
diff
(0..10).diff(0, |c, p| c - p)
(0..10).scan(0, |s, x| {
    let p = mem::replace(s, x);
    Some(x - p)
});

Versions

See CHANGELOG.

Commit count: 7

cargo fmt