simple_scan

Crates.iosimple_scan
lib.rssimple_scan
version0.3.1
sourcesrc
created_at2023-06-26 00:08:30.771358
updated_at2024-01-14 22:10:52.953604
descriptionIterator extensions for simple scan operation.
homepage
repositoryhttps://github.com/nossie531/simple_scan
max_upload_size
id899890
size24,293
(nossie531)

documentation

README

simple_scan

Iterator extension trait for simple scan.

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 simple version scan version

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)
});

What's New

v0.3.1

  • Minor refactoring.

v0.3.0

  • must_use annotations are added at several locations.

v0.2.1

  • Minor refactoring.

v0.2.0

  • changes trace2 behavior.

    In version 0.2, it track previous and current state.
    While in version 0.1, it track current state and current input.

Commit count: 6

cargo fmt