mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 13:37:48 +00:00
Use OsString for arguments rather than String
This commit is contained in:
parent
121ab6d847
commit
e8dcca1872
2 changed files with 16 additions and 1 deletions
|
@ -70,7 +70,22 @@ pub use crate::features::wide;
|
||||||
|
|
||||||
//## core functions
|
//## 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() ...
|
// args() ...
|
||||||
pub fn args() -> impl Iterator<Item = String> {
|
pub fn args() -> impl Iterator<Item = String> {
|
||||||
wild::args()
|
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);
|
proc_dbg!(&expr);
|
||||||
|
|
||||||
let f = quote::quote! { #expr(uucore::args().collect()) };
|
let f = quote::quote! { #expr(uucore::args_os()) };
|
||||||
proc_dbg!(&f);
|
proc_dbg!(&f);
|
||||||
|
|
||||||
// generate a uutils utility `main()` function, tailored for the calling utility
|
// generate a uutils utility `main()` function, tailored for the calling utility
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue