Crate snailx

Crate snailx 

Source
Expand description

snailx provides a simple, zero-allocation interface for iterating over program arguments.

This crate exposes lightweight, zero-copy iterators over program arguments:

  • Args::new yields CStr<’static>
  • MappedArgs::utf8 yields &'static str
    • if the assume_valid_str feature is enabled, all arguments are assumed to be valid UTF-8
    • if the assume_valid_str feature is disabled, invalid UTF-8 arguments are skipped
  • direct::argc_argv returns the raw (argc, argv)
  • MappedArgs::new lets you map each *const u8 argument pointer into a custom type; None values are skipped
  • MappedArgs::osstr (with the std feature) yields &'static std::ffi::OsStr

no_std by default; enable the std feature for OsStr support. Targets Unix-like systems and macOS.

Modules§

direct
Direct, platform-specific access to argc and argv. Most users should prefer the higher-level iterators in the crate root.
indexing_parser
A parser which indexes arguments, but requires allocation, and all related datatypes.

Structs§

Args
An iterator over program arguments as CStr<’static>.
CStr
A minimal CStr implementation for use in place of core::ffi::CStr (unstable before 1.64) and std::ffi::CStr (requires std).
MappedArgs
An iterator that maps each argument using a user-provided function. If the mapping returns None, that argument is skipped.

Type Aliases§

StdCStr
Alias for stdlib’s CStr.