| Crates.io | skip-if |
| lib.rs | skip-if |
| version | 0.1.1 |
| created_at | 2025-02-26 07:40:02.838027+00 |
| updated_at | 2025-02-26 07:58:40.315228+00 |
| description | Attribute macro to skip running a function that produces files |
| homepage | |
| repository | https://github.com/cpg314/skip-if |
| max_upload_size | |
| id | 1570113 |
| size | 25,380 |
This Rust attribute macro skips running a function that produces a file or a folder (output) depending on a strategy.
#[skip_if(output="avatars.join(name)", strategy="...")]
fn render_avatar(name: &str, avatars: &Path) -> anyhow::Result<()> {
// This will be skipped depending on the strategy.
// e.g. do not run if the output already exists or if the function previously
// failed on these arguments.
Ok(())
}
The strategy (specified in the strategy attribute) has access to:
args_skip attributes);output attribute).For convenience, the function on which the skip_if attribute is applied can access the value of the output expression through the skip_if_output variable.
The simplest strategy, skip_if::FileExists, is to skip when the output path exists.
#[skip_if(output = "output", strategy = "skip_if::FileExists")]
A more advanced strategy, skip_if::Markers, offers the following options:
{output}.success) with source and arguments hashes to never skip when these change, even if the output file already exists.{output}.failure) to skip after a failure.
success and failure markers are stored inside.#[skip_if(
output = "output",
strategy = "skip_if::Markers::default()",
// or:
// strategy = "skip_if::Markers::default().folder()",
)]