Skip to content

Commit

Permalink
Add doc links to README
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrankel committed Aug 1, 2024
1 parent 9e56afe commit df1f6b9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# Tiny failure-skipping macros
# tiny_bail

[![Crates.io](https://img.shields.io/crates/v/tiny_bail.svg)](https://crates.io/crates/tiny_bail)
[![Docs](https://docs.rs/tiny_bail/badge.svg)](https://docs.rs/tiny_bail/latest/tiny_bail/)
[![License](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](https://github.com/benfrankel/tiny_bail)

This crate provides four failure-skipping macros: `r!`, `rq!`, `c!`, and `cq!`; along with their long-form aliases
`or_return!`, `or_return_quiet!`, `or_continue!`, and `or_continue_quiet!`, respectively.
This crate provides four failure-skipping macros:
[`r!`](https://docs.rs/tiny_bail/latest/tiny_bail/macro.r.html),
[`rq!`](https://docs.rs/tiny_bail/latest/tiny_bail/macro.rq.html),
[`c!`](https://docs.rs/tiny_bail/latest/tiny_bail/macro.c.html), and
[`cq!`](https://docs.rs/tiny_bail/latest/tiny_bail/macro.cq.html); along with their long-form aliases
[`or_return!`](https://docs.rs/tiny_bail/latest/tiny_bail/macro.or_return.html),
[`or_return_quiet!`](https://docs.rs/tiny_bail/latest/tiny_bail/macro.or_return_quiet.html),
[`or_continue!`](https://docs.rs/tiny_bail/latest/tiny_bail/macro.or_continue.html), and
[`or_continue_quiet!`](https://docs.rs/tiny_bail/latest/tiny_bail/macro.or_continue_quiet.html), respectively.

The macros support both `Option` and `Result` types out-of-the-box. This can be extended by implementing the
`Success` trait for other types.
[`Success`](https://docs.rs/tiny_bail/latest/tiny_bail/trait.Success.html) trait for other types.

You can provide a return value as an optional first argument to the macro, or you can omit it to default to
`Default::default()`—which also works in functions with no return value.
Expand All @@ -25,7 +32,7 @@ fn increment_last(list: &mut [usize]) {
if let Some(x) = list.last_mut() {
*x += 1;
} else {
warn!("Empty list");
warn!("Bailed at src/foo.rs:34:18 `list.last_mut()`");
return;
}
}
Expand Down

0 comments on commit df1f6b9

Please sign in to comment.