#![forbid(unsafe_code, future_incompatible)]
#![deny(missing_debug_implementations, bad_style)]
#![warn(missing_docs)]
#![cfg_attr(test, deny(warnings))]
use std::env::{Args as StdArgs, ArgsOs as StdArgsOs};
use std::ffi::OsString;
use std::fmt;
use std::iter::Iterator;
#[doc(inline)]
#[cfg(not(test))] pub use paw_attributes::main;
#[doc(inline)]
pub use paw_raw::ParseArgs;
pub struct Args {
inner: StdArgs,
}
impl fmt::Debug for Args {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.inner.fmt(f)
}
}
impl Iterator for Args {
type Item = String;
fn next(&mut self) -> Option<Self::Item> {
self.inner.next()
}
}
impl ExactSizeIterator for Args {
fn len(&self) -> usize {
self.inner.len()
}
}
impl DoubleEndedIterator for Args {
fn next_back(&mut self) -> Option<String> {
self.inner.next_back()
}
}
impl ParseArgs for Args {
type Error = std::io::Error;
fn parse_args() -> Result<Self, Self::Error> {
Ok(Self {
inner: std::env::args(),
})
}
}
pub struct ArgsOs {
inner: StdArgsOs,
}
impl fmt::Debug for ArgsOs {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.inner.fmt(f)
}
}
impl Iterator for ArgsOs {
type Item = OsString;
fn next(&mut self) -> Option<Self::Item> {
self.inner.next()
}
}
impl ExactSizeIterator for ArgsOs {
fn len(&self) -> usize {
self.inner.len()
}
}
impl DoubleEndedIterator for ArgsOs {
fn next_back(&mut self) -> Option<OsString> {
self.inner.next_back()
}
}
impl ParseArgs for ArgsOs {
type Error = std::io::Error;
fn parse_args() -> Result<Self, Self::Error> {
Ok(Self {
inner: std::env::args_os(),
})
}
}