Skip to main content

ArgV

Trait ArgV 

Source
pub trait ArgV: Sealed {
    // Required method
    fn into_argv(self) -> Cow<'static, str>;
}
Expand description

Trait for types that can be converted into strings for use as command-line arguments.

This trait is implemented for common string types and enables the library to work with different argument representations. It is sealed and cannot be implemented outside of this crate.

Borrowed implementations are bounded by 'static so they can flow through the parser as Cow::Borrowed without allocation. This makes the crate a good fit for sources like the argv crate, which yields &'static OsStr. Owned types (String, OsString) have no lifetime constraint.

§Implementations

  • &'static str - String slices (zero-copy)
  • String - Owned strings (zero-copy, takes ownership)
  • &'static CStr - C-style nul-terminated strings (zero-copy when valid UTF-8)
  • OsString - Platform-native strings (zero-copy when valid UTF-8; requires std)
  • &'static OsStr - Borrowed platform-native strings (zero-copy when valid UTF-8; requires std)

Required Methods§

Source

fn into_argv(self) -> Cow<'static, str>

Converts self into a Cow<'static, str>.

For OsString/OsStr/CStr, invalid UTF-8 sequences are replaced with the Unicode replacement character (U+FFFD), which forces an allocation. Valid UTF-8 input is passed through without copying.

Implementations on Foreign Types§

Source§

impl ArgV for &&'static str

Source§

fn into_argv(self) -> Cow<'static, str>

Source§

impl ArgV for &'static str

Source§

fn into_argv(self) -> Cow<'static, str>

Source§

impl ArgV for &'static CStr

Source§

fn into_argv(self) -> Cow<'static, str>

Source§

impl ArgV for &'static OsStr

Available on crate feature std only.
Source§

fn into_argv(self) -> Cow<'static, str>

Source§

impl ArgV for String

Source§

fn into_argv(self) -> Cow<'static, str>

Source§

impl ArgV for OsString

Available on crate feature std only.
Source§

fn into_argv(self) -> Cow<'static, str>

Implementors§