mirror of
https://github.com/uutils/uucore.git
synced 2026-06-10 15:48:52 -07:00
Merge pull request #12 from Arcterus/args-osstring
Use OsString for arguments rather than String
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user