#![allow(clippy::undocumented_unsafe_blocks)]
use core::{fmt, str};
use crate::{io, sys::env as sys};
#[must_use = "iterators are lazy and do nothing unless consumed"]
pub struct Args<const BUF_SIZE: usize>(sys::ArgsBytes<BUF_SIZE>);
pub fn args<const BUF_SIZE: usize>() -> io::Result<Args<BUF_SIZE>> {
sys::args_bytes().map(Args)
}
#[allow(clippy::copy_iterator)] impl<'a, const BUF_SIZE: usize> Iterator for &'a Args<BUF_SIZE> {
type Item = Result<&'a str, str::Utf8Error>;
fn next(&mut self) -> Option<Self::Item> {
let arg = sys::next(&self.0)?;
Some(str::from_utf8(arg))
}
}
impl<const BUF_SIZE: usize> fmt::Debug for Args<BUF_SIZE> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Args").finish_non_exhaustive()
}
}