Skip to content

Commit

Permalink
Add long-form aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrankel committed Aug 1, 2024
1 parent f69ad13 commit b8df191
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Tiny failure skipping macros
# Tiny failure-skipping macros

[![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/)
Expand Down
38 changes: 37 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Tiny failure skipping macros.
//! Tiny failure-skipping macros.
// TODO: Expand module-level docs.

/// An extension trait for extracting success from failure types.
Expand Down Expand Up @@ -62,6 +62,15 @@ macro_rules! r {
};
}

/// A long-form alias for [`r!`].
#[doc(alias = "r")]
#[macro_export]
macro_rules! or_return {
($tt:tt) => {
$crate::r!($tt);
};
}

// TODO: Explain return value: default, or a provided value.
/// Unwrap or return quietly.
#[macro_export]
Expand All @@ -81,6 +90,15 @@ macro_rules! rq {
};
}

/// A long-form alias for [`rq!`].
#[doc(alias = "rq")]
#[macro_export]
macro_rules! or_return_quiet {
($tt:tt) => {
$crate::rq!($tt);
};
}

/// Unwrap or continue with a warning.
#[macro_export]
macro_rules! c {
Expand All @@ -95,6 +113,15 @@ macro_rules! c {
};
}

/// A long-form alias for [`c!`].
#[doc(alias = "c")]
#[macro_export]
macro_rules! or_continue {
($tt:tt) => {
$crate::c!($tt);
};
}

/// Unwrap or continue quietly.
#[macro_export]
macro_rules! cq {
Expand All @@ -105,3 +132,12 @@ macro_rules! cq {
}
};
}

/// A long-form alias for [`cq!`].
#[doc(alias = "cq")]
#[macro_export]
macro_rules! or_continue_quiet {
($tt:tt) => {
$crate::cq!($tt);
};
}

0 comments on commit b8df191

Please sign in to comment.