From ef8f8e2b11ef55a8b5b409743441388eabc68c94 Mon Sep 17 00:00:00 2001 From: Carl Sverre <82591+carlsverre@users.noreply.github.com> Date: Wed, 6 Nov 2024 15:41:00 -0800 Subject: [PATCH] tweak workflow, update readme with badges --- .github/workflows/rust.yml | 20 ++++++++++---------- README.md | 26 +++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 1a96bd9..9143c9d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -2,21 +2,21 @@ name: Build + Test on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] env: CARGO_TERM_COLOR: always jobs: - build: + build_and_test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose - - name: Check - run: cargo check --verbose + - uses: actions/checkout@v4 + - name: Build + run: cargo build --verbose + - name: Run tests + run: cargo test --verbose + - name: Check + run: cargo check --verbose diff --git a/README.md b/README.md index f1f2503..f6cd9d3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,17 @@ -# tryiter +

tryiter

+

+ + docs.rs + + + crates.io + + + Build Status + +

+ + Utility functions for Iterators of Results. This crate is heavily inspired by [TryStreamExt] in the [futures] crate. [futures]: https://docs.rs/futures @@ -7,3 +20,14 @@ Utility functions for Iterators of Results. This crate is heavily inspired by [T ## `TryIteratorExt` This crate exports a trait called `TryIteratorExt` which provides utility methods on top of any Iterator which returns a `Result`. `TryIteratorExt` is automatically implemented on top of compatible Iterators via a generic `impl` so all you have to do is import the trait and start calling methods on your iterators. + +**Example:** +```rust +use tryiter::TryIteratorExt; + +let iter = vec![Ok(1), Ok(2), Ok(3), Err("error")].into_iter(); +let mut evens = iter.try_filter(|x| x % 2 == 0); + +assert_eq!(evens.next(), Some(Ok(2))); +assert_eq!(evens.next(), Some(Err("error"))); +```