arg_attr 0.1.0

Specify the accepted arguments depending on configuration conditional checks.
Documentation
  • Coverage
  • 50%
    1 out of 2 items documented1 out of 2 items with examples
  • Size
  • Source code size: 5.4 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 277.7 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • JohnScience/arg_attr
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • JohnScience

arg_attr

Crates.io Downloads Documentation License Dependency Status

Specify the accepted arguments depending on configuration conditional checks.

Examples

Simple yet silly example:

#![allow(dead_code)]

use arg_attr::args;

#[args(_url: String)]
fn silly_drop() {
    drop(_url);
}

In the example above, args attribute unconditionally specifies the arguments for the silly_drop function. On it's own it is fairly useless, but it can be used in combination with #[cfg_attr(...)] for conditional compilation.

use pyo3::prelude::Python;
use qualifier_attr::qualifiers;
use arg_attr::args;

// At the moment of writing, `pyo3` does not support async functions.
// https://github.com/PyO3/pyo3/issues/1632
#[cfg_attr(feature="python", args(py: Python<'_>, url: &'str))]
#[cfg_attr(not(feature="python"), args(url: &'str), qualifiers(async))]
fn fetch() {
    todo!()
}

Related crates