1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-31 13:07:46 +00:00

Use OsString for arguments rather than String

This commit is contained in:
Alex Lyon 2020-06-16 01:27:12 -05:00 committed by Roy Ivy III
parent 121ab6d847
commit e8dcca1872
2 changed files with 16 additions and 1 deletions

View file

@ -70,7 +70,22 @@ pub use crate::features::wide;
//## core functions
use std::ffi::OsString;
pub trait Args: Iterator<Item = OsString> + Sized {
fn collect_str(self) -> Vec<String> {
// FIXME: avoid unwrap()
self.map(|s| s.into_string().unwrap()).collect()
}
}
impl<T: Iterator<Item = OsString> + Sized> Args for T { }
// args() ...
pub fn args() -> impl Iterator<Item = String> {
wild::args()
}
pub fn args_os() -> impl Iterator<Item = OsString> {
wild::args_os()
}

View file

@ -69,7 +69,7 @@ pub fn main(stream: proc_macro::TokenStream) -> proc_macro::TokenStream {
};
proc_dbg!(&expr);
let f = quote::quote! { #expr(uucore::args().collect()) };
let f = quote::quote! { #expr(uucore::args_os()) };
proc_dbg!(&f);
// generate a uutils utility `main()` function, tailored for the calling utility