Skip to content

Commit

Permalink
Prepare 1.0.0 (#15)
Browse files Browse the repository at this point in the history
- Breaking change: `ErrorIter` trait is now named `ErrorExt`.
  • Loading branch information
parasyte committed Jul 10, 2023
1 parent efdae6f commit 8d117e8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "error-iter"
description = "Error::sources on stable Rust"
repository = "https://github.com/parasyte/error-iter"
version = "0.4.1"
version = "1.0.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
readme = "README.md"
Expand All @@ -14,7 +14,7 @@ license = "MIT"
rust-version = "1.37"

[badges]
maintenance = { status = "experimental" }
maintenance = { status = "passively-maintained" }

[dev-dependencies]
thiserror = "=1.0.39"
9 changes: 5 additions & 4 deletions examples/simple.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
use error_iter::ErrorIter as _;
use std::io::{Error as IoError, ErrorKind};
use error_iter::ErrorExt as _;
use std::io;
use thiserror::Error;

#[derive(Debug, Error)]
enum Error {
#[error("I/O Error")]
Io(#[from] IoError),
Io(#[from] io::Error),

#[error("Unknown error")]
_Unknown,
}

fn main() {
let error = Error::from(IoError::new(ErrorKind::Other, "oh no!"));
let inner = io::Error::new(io::ErrorKind::Other, "oh no!");
let error = Error::from(inner);

eprintln!("Error: {}", error);
for source in error.sources().skip(1) {
Expand Down
15 changes: 8 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
//! Iterators over `std::error::Error` sources on stable Rust.
//!
//! ```
//! use error_iter::ErrorIter as _;
//! use std::io::{Error as IoError, ErrorKind};
//! use error_iter::ErrorExt as _;
//! use std::io;
//! use thiserror::Error;
//!
//! #[derive(Debug, Error)]
//! enum Error {
//! #[error("I/O Error")]
//! Io(#[from] IoError),
//! Io(#[from] io::Error),
//!
//! #[error("Unknown error")]
//! Unknown,
//! }
//!
//! fn do_something() {
//! let error = Error::from(IoError::new(ErrorKind::Other, "oh no!"));
//! let inner = io::Error::new(io::ErrorKind::Other, "oh no!");
//! let error = Error::from(inner);
//!
//! eprintln!("Error: {}", error);
//! for source in error.sources().skip(1) {
Expand Down Expand Up @@ -48,11 +49,11 @@ impl<'a> Iterator for ErrorIterator<'a> {
/// Implement this trait on your error types for free iterators over their sources!
///
/// The default implementation provides iterators for any type that implements `std::error::Error`.
pub trait ErrorIter: std::error::Error + Sized + 'static {
pub trait ErrorExt: std::error::Error + Sized + 'static {
/// Create an iterator over the error and its recursive sources.
///
/// ```
/// use error_iter::ErrorIter as _;
/// use error_iter::ErrorExt as _;
/// use thiserror::Error;
///
/// #[derive(Debug, Error)]
Expand All @@ -78,7 +79,7 @@ pub trait ErrorIter: std::error::Error + Sized + 'static {
}
}

impl<T> ErrorIter for T where T: std::error::Error + Sized + 'static {}
impl<T> ErrorExt for T where T: std::error::Error + Sized + 'static {}

#[cfg(test)]
mod tests {
Expand Down

0 comments on commit 8d117e8

Please sign in to comment.