Skip to main content

Occurrence

Trait Occurrence 

Source
pub trait Occurrence: Sized {
    const PREFIXES: &'static [u8] = _;
    const ITEMS: &'static [Item] = _;
    const POSITIONAL: bool = false;
    const BUNDLES: bool = false;

    // Required methods
    fn from_arg<'i>(
        arg: &Arg<'i>,
        input: &mut Argv<'i>,
    ) -> Result<Option<Self>, Error>;
    fn from_word(word: &Word<'_>) -> Result<Option<Self>, Error>;
    fn is_long(name: &[u8]) -> bool;

    // Provided methods
    fn from_bundle(word: &Word<'_>) -> Result<Option<Self>, Error> { ... }
    fn from_unknown(word: &Word<'_>) -> Result<Option<Self>, Error> { ... }
    fn short(letter: char) -> Option<bool> { ... }
}
Expand description

Flags and words kept in command-line order: an enum deriving Occurrence, one variant per flag or positional, collected by an #[arg(sequence)] Vec field of an Args struct.

For command lines where position is meaning, as ld’s: --as-needed and --whole-archive apply to the inputs after them, so the linker folds the sequence rather than reading fields.

Provided Associated Constants§

Source

const PREFIXES: &'static [u8] = _

Letters that always take the rest of their word (-lfoo), for a long_only parent: no single-dash long name starting with one is tried.

Source

const ITEMS: &'static [Item] = _

The variants as help lists them, after the parent’s own flags.

Source

const POSITIONAL: bool = false

Whether there is a positional variant: each plain word is that variant.

Source

const BUNDLES: bool = false

Whether there is an #[arg(bundle)] variant.

Required Methods§

Source

fn from_arg<'i>( arg: &Arg<'i>, input: &mut Argv<'i>, ) -> Result<Option<Self>, Error>

arg as one of the variants, its value read from input; None when no variant is spelled so.

Source

fn from_word(word: &Word<'_>) -> Result<Option<Self>, Error>

A word as the positional variant; None if there is none.

Source

fn is_long(name: &[u8]) -> bool

Whether name is a variant’s long name that may be spelled with one dash, for a long_only parent.

Provided Methods§

Source

fn from_bundle(word: &Word<'_>) -> Result<Option<Self>, Error>

A word of several short flags (-sS), whole, as the #[arg(bundle)] variant: an item put before those of its letters, whoever takes them, for a program that reports grouping (GNU ld deprecates it). None if there is none.

Source

fn from_unknown(word: &Word<'_>) -> Result<Option<Self>, Error>

A flag no variant names, as the #[arg(unknown)] variant; None if there is none. Asked by a parent whose field is #[arg(sequence, unknown)].

Source

fn short(letter: char) -> Option<bool>

Whether letter is a variant’s short flag, and whether it takes a value: how a parent with an unknown field tells an unknown bundle.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§