Skip to content

Commit

Permalink
updated homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
blkmlk committed Aug 3, 2024
1 parent 299c383 commit ef14557
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "match_err"
version = "0.1.6"
version = "0.1.7"
edition = "2021"
homepage = "https://github.com/blkmlk/match_err"
documentation = "https://docs.rs/match_err"
Expand Down
38 changes: 38 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
//! # match_err
//!
//! Macro for quick matching errors against enum-like error types
//!
//! Helps to avoid writing long and tedious structures like:
//! ```rust
//! if let Err(e) = err {
//! if let Some(e) = e.downcast_ref::<Error>() {
//! match e {
//! ...
//! }
//! }
//! }
//! ```
//!
//! ## Examples
//!
//! ```rust
//! use match_err::*;
//!
//! #[derive(thiserror::Error, Debug)]
//! enum Error {
//! #[error("not found")]
//! NotFound,
//! #[error("custom: {0}")]
//! Custom(String),
//! }
//!
//! let err: Result<(), _> = Err(anyhow!(Error::NotFound));
//!
//! match_if_err!(err, Error, {
//! NotFound => println!("not found"),
//! Custom(msg) => println!("custom message: {}", msg),
//! _ => println!("unknown")
//! })
//! ```


/// Matches an error against an enum-like error type by hiding the usage of downcast_ref method
///
/// # Examples
Expand Down

0 comments on commit ef14557

Please sign in to comment.