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

Format everything using rustfmt

This commit is contained in:
Alex Lyon 2018-03-12 01:20:58 -07:00 committed by Roy Ivy III
parent 1c0b1ab375
commit f74a1b6333
12 changed files with 418 additions and 176 deletions

View file

@ -1,56 +1,84 @@
extern crate getopts;
pub struct HelpText<'a> {
pub name : &'a str,
pub version : &'a str,
pub syntax : &'a str,
pub summary : &'a str,
pub long_help : &'a str,
pub display_usage : bool
pub name: &'a str,
pub version: &'a str,
pub syntax: &'a str,
pub summary: &'a str,
pub long_help: &'a str,
pub display_usage: bool,
}
pub struct CoreOptions<'a> {
options : getopts::Options,
help_text : HelpText<'a>
options: getopts::Options,
help_text: HelpText<'a>,
}
impl<'a> CoreOptions<'a> {
pub fn new(help_text: HelpText<'a>) -> Self {
let mut ret = CoreOptions {
options : getopts::Options::new(),
help_text : help_text
options: getopts::Options::new(),
help_text: help_text,
};
ret.options
.optflag("", "help", "print usage information")
.optflag("", "version", "print name and version number");
ret
}
pub fn optflagopt(&mut self, short_name: &str, long_name: &str, desc: &str, hint: &str) -> &mut CoreOptions<'a> {
pub fn optflagopt(
&mut self,
short_name: &str,
long_name: &str,
desc: &str,
hint: &str,
) -> &mut CoreOptions<'a> {
self.options.optflagopt(short_name, long_name, desc, hint);
self
}
pub fn optflag(&mut self, short_name: &str, long_name: &str, desc: &str) -> &mut CoreOptions<'a> {
pub fn optflag(
&mut self,
short_name: &str,
long_name: &str,
desc: &str,
) -> &mut CoreOptions<'a> {
self.options.optflag(short_name, long_name, desc);
self
}
pub fn optflagmulti(&mut self, short_name: &str, long_name: &str, desc: &str) -> &mut CoreOptions<'a> {
pub fn optflagmulti(
&mut self,
short_name: &str,
long_name: &str,
desc: &str,
) -> &mut CoreOptions<'a> {
self.options.optflagmulti(short_name, long_name, desc);
self
}
pub fn optopt(&mut self, short_name: &str, long_name: &str, desc: &str, hint: &str) -> &mut CoreOptions<'a> {
pub fn optopt(
&mut self,
short_name: &str,
long_name: &str,
desc: &str,
hint: &str,
) -> &mut CoreOptions<'a> {
self.options.optopt(short_name, long_name, desc, hint);
self
}
pub fn optmulti(&mut self, short_name: &str, long_name: &str, desc: &str, hint: &str) -> &mut CoreOptions<'a> {
pub fn optmulti(
&mut self,
short_name: &str,
long_name: &str,
desc: &str,
hint: &str,
) -> &mut CoreOptions<'a> {
self.options.optmulti(short_name, long_name, desc, hint);
self
}
pub fn usage(&self, summary : &str) -> String {
pub fn usage(&self, summary: &str) -> String {
self.options.usage(summary)
}
pub fn parse(&mut self, args : Vec<String>) -> getopts::Matches {
pub fn parse(&mut self, args: Vec<String>) -> getopts::Matches {
let matches = match self.options.parse(&args[1..]) {
Ok(m) => { Some(m) },
Ok(m) => Some(m),
Err(f) => {
eprint!("{}: error: ", self.help_text.name);
eprintln!("{}", f);
@ -59,16 +87,26 @@ impl<'a> CoreOptions<'a> {
}.unwrap();
if matches.opt_present("help") {
let usage_str = if self.help_text.display_usage {
format!("\n {}\n\n Reference\n",
self.options.usage(self.help_text.summary)
).replace("Options:", " Options:")
} else { String::new() };
print!("
format!(
"\n {}\n\n Reference\n",
self.options.usage(self.help_text.summary)
).replace("Options:", " Options:")
} else {
String::new()
};
print!(
"
{0} {1}
{0} {2}
{3}{4}
", self.help_text.name, self.help_text.version, self.help_text.syntax, usage_str, self.help_text.long_help);
",
self.help_text.name,
self.help_text.version,
self.help_text.syntax,
usage_str,
self.help_text.long_help
);
exit!(0);
} else if matches.opt_present("version") {
println!("{} {}", self.help_text.name, self.help_text.version);

View file

@ -7,7 +7,7 @@
//
extern crate data_encoding;
use self::data_encoding::{base64, base32, decode};
use self::data_encoding::{decode, base32, base64};
use std::io::Read;
pub type DecodeResult = Result<Vec<u8>, decode::Error>;
@ -70,12 +70,12 @@ impl<R: Read> Data<R> {
self.input.read_to_string(&mut buf).unwrap();
let clean = if self.ignore_garbage {
buf.chars()
.filter(|&c| self.alphabet.contains(c))
.collect::<String>()
.filter(|&c| self.alphabet.contains(c))
.collect::<String>()
} else {
buf.chars()
.filter(|&c| c != '\r' && c != '\n')
.collect::<String>()
.filter(|&c| c != '\r' && c != '\n')
.collect::<String>()
};
decode(self.format, clean.as_bytes())
}

View file

@ -27,24 +27,29 @@
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
use libc::time_t;
use libc::{uid_t, gid_t, c_char, c_int};
use libc::{passwd, group, getpwnam, getpwuid, getgrnam, getgrgid, getgroups};
use libc::{c_char, c_int, gid_t, uid_t};
use libc::{getgrgid, getgrnam, getgroups, getpwnam, getpwuid, group, passwd};
use ::std::ptr;
use ::std::io::ErrorKind;
use ::std::io::Error as IOError;
use ::std::io::Result as IOResult;
use ::std::ffi::{CStr, CString};
use ::std::borrow::Cow;
use std::ptr;
use std::io::ErrorKind;
use std::io::Error as IOError;
use std::io::Result as IOResult;
use std::ffi::{CStr, CString};
use std::borrow::Cow;
extern "C" {
fn getgrouplist(name: *const c_char, gid: gid_t, groups: *mut gid_t, ngroups: *mut c_int) -> c_int;
fn getgrouplist(
name: *const c_char,
gid: gid_t,
groups: *mut gid_t,
ngroups: *mut c_int,
) -> c_int;
}
pub fn get_groups() -> IOResult<Vec<gid_t>> {
let ngroups = unsafe { getgroups(0, ptr::null_mut()) };
if ngroups == -1 {
return Err(IOError::last_os_error())
return Err(IOError::last_os_error());
}
let mut groups = Vec::with_capacity(ngroups as usize);
let ngroups = unsafe { getgroups(ngroups, groups.as_mut_ptr()) };
@ -173,7 +178,9 @@ impl Group {
/// Fetch desired entry.
pub trait Locate<K> {
fn locate(key: K) -> IOResult<Self> where Self: ::std::marker::Sized;
fn locate(key: K) -> IOResult<Self>
where
Self: ::std::marker::Sized;
}
macro_rules! f {

View file

@ -31,9 +31,9 @@ pub fn resolve_relative_path<'a>(path: &'a Path) -> Cow<'a, Path> {
result.pop();
}
Component::CurDir => (),
Component::RootDir |
Component::Normal(_) |
Component::Prefix(_) => result.push(comp.as_os_str()),
Component::RootDir | Component::Normal(_) | Component::Prefix(_) => {
result.push(comp.as_os_str())
}
}
}
result.into()
@ -53,7 +53,10 @@ fn resolve<P: AsRef<Path>>(original: P) -> IOResult<PathBuf> {
let mut result = original.as_ref().to_path_buf();
loop {
if followed == MAX_LINKS_FOLLOWED {
return Err(Error::new(ErrorKind::InvalidInput, "maximum links followed"));
return Err(Error::new(
ErrorKind::InvalidInput,
"maximum links followed",
));
}
match fs::symlink_metadata(&result) {
@ -93,8 +96,7 @@ pub fn canonicalize<P: AsRef<Path>>(original: P, can_mode: CanonicalizeMode) ->
// vector for canonicalization.
for part in original.components() {
match part {
Component::Prefix(_) |
Component::RootDir => {
Component::Prefix(_) | Component::RootDir => {
result.push(part.as_os_str());
}
Component::CurDir => (),
@ -117,12 +119,10 @@ pub fn canonicalize<P: AsRef<Path>>(original: P, can_mode: CanonicalizeMode) ->
}
match resolve(&result) {
Err(e) => {
match can_mode {
CanonicalizeMode::Missing => continue,
_ => return Err(e),
}
}
Err(e) => match can_mode {
CanonicalizeMode::Missing => continue,
_ => return Err(e),
},
Ok(path) => {
result.pop();
result.push(path);

View file

@ -15,20 +15,22 @@ pub fn parse_numeric(fperm: u32, mut mode: &str) -> Result<u32, String> {
Err(format!("mode is too large ({} > 7777)", mode))
} else {
match u32::from_str_radix(mode, 8) {
Ok(change) => {
Ok(match op {
'+' => fperm | change,
'-' => fperm & !change,
'=' => change,
_ => unreachable!()
})
}
Err(err) => Err(err.description().to_owned())
Ok(change) => Ok(match op {
'+' => fperm | change,
'-' => fperm & !change,
'=' => change,
_ => unreachable!(),
}),
Err(err) => Err(err.description().to_owned()),
}
}
}
pub fn parse_symbolic(mut fperm: u32, mut mode: &str, considering_dir: bool) -> Result<u32, String> {
pub fn parse_symbolic(
mut fperm: u32,
mut mode: &str,
considering_dir: bool,
) -> Result<u32, String> {
#[cfg(unix)]
use libc::umask;
@ -43,9 +45,7 @@ pub fn parse_symbolic(mut fperm: u32, mut mode: &str, considering_dir: bool) ->
return Err(format!("invalid mode ({})", mode));
}
let respect_umask = pos == 0;
let last_umask = unsafe {
umask(0)
};
let last_umask = unsafe { umask(0) };
mode = &mode[pos..];
while mode.len() > 0 {
let (op, pos) = parse_op(mode, None)?;
@ -59,7 +59,7 @@ pub fn parse_symbolic(mut fperm: u32, mut mode: &str, considering_dir: bool) ->
'+' => fperm |= srwx & mask,
'-' => fperm &= !(srwx & mask),
'=' => fperm = (fperm & !mask) | (srwx & mask),
_ => unreachable!()
_ => unreachable!(),
}
}
unsafe {
@ -77,12 +77,12 @@ fn parse_levels(mode: &str) -> (u32, usize) {
'g' => 0o7070,
'o' => 0o7007,
'a' => 0o7777,
_ => break
_ => break,
};
pos += 1;
}
if pos == 0 {
mask = 0o7777; // default to 'a'
mask = 0o7777; // default to 'a'
}
(mask, pos)
}
@ -93,10 +93,13 @@ fn parse_op(mode: &str, default: Option<char>) -> Result<(char, usize), String>
'+' | '-' | '=' => Ok((ch, 1)),
_ => match default {
Some(ch) => Ok((ch, 0)),
None => Err(format!("invalid operator (expected +, -, or =, but found {})", ch))
}
None => Err(format!(
"invalid operator (expected +, -, or =, but found {})",
ch
)),
},
},
None => Err("unexpected end of mode".to_owned())
None => Err("unexpected end of mode".to_owned()),
}
}
@ -118,7 +121,7 @@ fn parse_change(mode: &str, fperm: u32, considering_dir: bool) -> (u32, usize) {
'u' => srwx = (fperm & 0o700) | ((fperm >> 3) & 0o070) | ((fperm >> 6) & 0o007),
'g' => srwx = ((fperm << 3) & 0o700) | (fperm & 0o070) | ((fperm >> 3) & 0o007),
'o' => srwx = ((fperm << 6) & 0o700) | ((fperm << 3) & 0o070) | (fperm & 0o007),
_ => break
_ => break,
};
pos += 1;
}
@ -126,4 +129,4 @@ fn parse_change(mode: &str, fperm: u32, considering_dir: bool) -> (u32, usize) {
srwx = 0;
}
(srwx, pos)
}
}

View file

@ -1,6 +1,6 @@
use std::panic;
pub fn install_sigpipe_hook() {
pub fn install_sigpipe_hook() {
let hook = panic::take_hook();
panic::set_hook(Box::new(move |info| {
if let Some(res) = info.payload().downcast_ref::<String>() {

View file

@ -12,7 +12,7 @@ use std::time::Duration;
pub fn from_str(string: &str) -> Result<Duration, String> {
let len = string.len();
if len == 0 {
return Err("empty string".to_owned())
return Err("empty string".to_owned());
}
let slice = &string[..len - 1];
let (numstr, times) = match string.chars().next_back().unwrap() {
@ -26,13 +26,13 @@ pub fn from_str(string: &str) -> Result<Duration, String> {
} else if string == "inf" || string == "infinity" {
("inf", 1)
} else {
return Err(format!("invalid time interval '{}'", string))
return Err(format!("invalid time interval '{}'", string));
}
}
};
let num = match numstr.parse::<f64>() {
Ok(m) => m,
Err(e) => return Err(format!("invalid time interval '{}': {}", string, e))
Err(e) => return Err(format!("invalid time interval '{}': {}", string, e)),
};
const NANOS_PER_SEC: u32 = 1_000_000_000;

View file

@ -8,7 +8,7 @@
//
use super::libc;
use libc::{c_int, pid_t, uid_t, gid_t};
use libc::{c_int, gid_t, pid_t, uid_t};
use std::fmt;
use std::io;
use std::process::Child;
@ -17,27 +17,19 @@ use std::thread;
use std::time::{Duration, Instant};
pub fn geteuid() -> uid_t {
unsafe {
libc::geteuid()
}
unsafe { libc::geteuid() }
}
pub fn getegid() -> gid_t {
unsafe {
libc::getegid()
}
unsafe { libc::getegid() }
}
pub fn getgid() -> gid_t {
unsafe {
libc::getgid()
}
unsafe { libc::getgid() }
}
pub fn getuid() -> uid_t {
unsafe {
libc::getuid()
}
unsafe { libc::getuid() }
}
// This is basically sys::unix::process::ExitStatus
@ -109,7 +101,10 @@ impl ChildExt for Child {
fn wait_or_timeout(&mut self, timeout: Duration) -> io::Result<Option<ExitStatus>> {
// The result will be written to that Option, protected by a Mutex
// Then the Condvar will be signaled
let state = Arc::new((Mutex::new(Option::None::<io::Result<ExitStatus>>), Condvar::new()));
let state = Arc::new((
Mutex::new(Option::None::<io::Result<ExitStatus>>),
Condvar::new(),
));
// Start the waiting thread
let state_th = state.clone();

View file

@ -7,10 +7,12 @@
* that was distributed with this source code.
*/
pub static DEFAULT_SIGNAL:usize= 15;
pub static DEFAULT_SIGNAL: usize = 15;
pub struct Signal<'a> { pub name:&'a str, pub value: usize}
pub struct Signal<'a> {
pub name: &'a str,
pub value: usize,
}
/*
@ -26,41 +28,133 @@ Linux Programmer's Manual
*/
#[cfg(target_os = "linux")]
pub static ALL_SIGNALS:[Signal<'static>; 31] = [
Signal{ name: "HUP", value:1 },
Signal{ name: "INT", value:2 },
Signal{ name: "QUIT", value:3 },
Signal{ name: "ILL", value:4 },
Signal{ name: "TRAP", value:5 },
Signal{ name: "ABRT", value:6 },
Signal{ name: "BUS", value:7 },
Signal{ name: "FPE", value:8 },
Signal{ name: "KILL", value:9 },
Signal{ name: "USR1", value:10 },
Signal{ name: "SEGV", value:11 },
Signal{ name: "USR2", value:12 },
Signal{ name: "PIPE", value:13 },
Signal{ name: "ALRM", value:14 },
Signal{ name: "TERM", value:15 },
Signal{ name: "STKFLT", value:16 },
Signal{ name: "CHLD", value:17 },
Signal{ name: "CONT", value:18 },
Signal{ name: "STOP", value:19 },
Signal{ name: "TSTP", value:20 },
Signal{ name: "TTIN", value:21 },
Signal{ name: "TTOU", value:22 },
Signal{ name: "URG", value:23 },
Signal{ name: "XCPU", value:24 },
Signal{ name: "XFSZ", value:25 },
Signal{ name: "VTALRM", value:26 },
Signal{ name: "PROF", value:27 },
Signal{ name: "WINCH", value:28 },
Signal{ name: "POLL", value:29 },
Signal{ name: "PWR", value:30 },
Signal{ name: "SYS", value:31 },
pub static ALL_SIGNALS: [Signal<'static>; 31] = [
Signal {
name: "HUP",
value: 1,
},
Signal {
name: "INT",
value: 2,
},
Signal {
name: "QUIT",
value: 3,
},
Signal {
name: "ILL",
value: 4,
},
Signal {
name: "TRAP",
value: 5,
},
Signal {
name: "ABRT",
value: 6,
},
Signal {
name: "BUS",
value: 7,
},
Signal {
name: "FPE",
value: 8,
},
Signal {
name: "KILL",
value: 9,
},
Signal {
name: "USR1",
value: 10,
},
Signal {
name: "SEGV",
value: 11,
},
Signal {
name: "USR2",
value: 12,
},
Signal {
name: "PIPE",
value: 13,
},
Signal {
name: "ALRM",
value: 14,
},
Signal {
name: "TERM",
value: 15,
},
Signal {
name: "STKFLT",
value: 16,
},
Signal {
name: "CHLD",
value: 17,
},
Signal {
name: "CONT",
value: 18,
},
Signal {
name: "STOP",
value: 19,
},
Signal {
name: "TSTP",
value: 20,
},
Signal {
name: "TTIN",
value: 21,
},
Signal {
name: "TTOU",
value: 22,
},
Signal {
name: "URG",
value: 23,
},
Signal {
name: "XCPU",
value: 24,
},
Signal {
name: "XFSZ",
value: 25,
},
Signal {
name: "VTALRM",
value: 26,
},
Signal {
name: "PROF",
value: 27,
},
Signal {
name: "WINCH",
value: 28,
},
Signal {
name: "POLL",
value: 29,
},
Signal {
name: "PWR",
value: 30,
},
Signal {
name: "SYS",
value: 31,
},
];
/*
@ -103,38 +197,131 @@ No Name Default Action Description
*/
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
pub static ALL_SIGNALS:[Signal<'static>; 31] = [
Signal{ name: "HUP", value:1 },
Signal{ name: "INT", value:2 },
Signal{ name: "QUIT", value:3 },
Signal{ name: "ILL", value:4 },
Signal{ name: "TRAP", value:5 },
Signal{ name: "ABRT", value:6 },
Signal{ name: "EMT", value:7 },
Signal{ name: "FPE", value:8 },
Signal{ name: "KILL", value:9 },
Signal{ name: "BUS", value:10 },
Signal{ name: "SEGV", value:11 },
Signal{ name: "SYS", value:12 },
Signal{ name: "PIPE", value:13 },
Signal{ name: "ALRM", value:14 },
Signal{ name: "TERM", value:15 },
Signal{ name: "URG", value:16 },
Signal{ name: "STOP", value:17 },
Signal{ name: "TSTP", value:18 },
Signal{ name: "CONT", value:19 },
Signal{ name: "CHLD", value:20 },
Signal{ name: "TTIN", value:21 },
Signal{ name: "TTOU", value:22 },
Signal{ name: "IO", value:23 },
Signal{ name: "XCPU", value:24 },
Signal{ name: "XFSZ", value:25 },
Signal{ name: "VTALRM", value:26 },
Signal{ name: "PROF", value:27 },
Signal{ name: "WINCH", value:28 },
Signal{ name: "INFO", value:29 },
Signal{ name: "USR1", value:30 },
Signal{ name: "USR2", value:31 },
pub static ALL_SIGNALS: [Signal<'static>; 31] = [
Signal {
name: "HUP",
value: 1,
},
Signal {
name: "INT",
value: 2,
},
Signal {
name: "QUIT",
value: 3,
},
Signal {
name: "ILL",
value: 4,
},
Signal {
name: "TRAP",
value: 5,
},
Signal {
name: "ABRT",
value: 6,
},
Signal {
name: "EMT",
value: 7,
},
Signal {
name: "FPE",
value: 8,
},
Signal {
name: "KILL",
value: 9,
},
Signal {
name: "BUS",
value: 10,
},
Signal {
name: "SEGV",
value: 11,
},
Signal {
name: "SYS",
value: 12,
},
Signal {
name: "PIPE",
value: 13,
},
Signal {
name: "ALRM",
value: 14,
},
Signal {
name: "TERM",
value: 15,
},
Signal {
name: "URG",
value: 16,
},
Signal {
name: "STOP",
value: 17,
},
Signal {
name: "TSTP",
value: 18,
},
Signal {
name: "CONT",
value: 19,
},
Signal {
name: "CHLD",
value: 20,
},
Signal {
name: "TTIN",
value: 21,
},
Signal {
name: "TTOU",
value: 22,
},
Signal {
name: "IO",
value: 23,
},
Signal {
name: "XCPU",
value: 24,
},
Signal {
name: "XFSZ",
value: 25,
},
Signal {
name: "VTALRM",
value: 26,
},
Signal {
name: "PROF",
value: 27,
},
Signal {
name: "WINCH",
value: 28,
},
Signal {
name: "INFO",
value: 29,
},
Signal {
name: "USR1",
value: 30,
},
Signal {
name: "USR2",
value: 31,
},
];
pub fn signal_by_name_or_value(signal_name_or_value: &str) -> Option<usize> {
@ -143,7 +330,9 @@ pub fn signal_by_name_or_value(signal_name_or_value: &str) -> Option<usize> {
}
for signal in &ALL_SIGNALS {
let long_name = format!("SIG{}", signal.name);
if signal.name == signal_name_or_value || (signal_name_or_value == signal.value.to_string()) || (long_name == signal_name_or_value) {
if signal.name == signal_name_or_value || (signal_name_or_value == signal.value.to_string())
|| (long_name == signal_name_or_value)
{
return Some(signal.value);
}
}

View file

@ -25,4 +25,3 @@ static UTF8_CHAR_WIDTH: [u8; 256] = [
pub fn utf8_char_width(b: u8) -> usize {
return UTF8_CHAR_WIDTH[b as usize] as usize;
}

View file

@ -33,12 +33,12 @@
use super::libc;
pub extern crate time;
use self::time::{Tm, Timespec};
use self::time::{Timespec, Tm};
use ::std::io::Result as IOResult;
use ::std::io::Error as IOError;
use ::std::ptr;
use ::std::ffi::CString;
use std::io::Result as IOResult;
use std::io::Error as IOError;
use std::ptr;
use std::ffi::CString;
pub use self::ut::*;
use libc::utmpx;
@ -159,8 +159,10 @@ impl Utmpx {
}
/// A.K.A. ut.ut_tv
pub fn login_time(&self) -> Tm {
time::at(Timespec::new(self.inner.ut_tv.tv_sec as i64,
self.inner.ut_tv.tv_usec as i32))
time::at(Timespec::new(
self.inner.ut_tv.tv_sec as i64,
self.inner.ut_tv.tv_usec as i32,
))
}
/// A.K.A. ut.ut_exit
///
@ -202,10 +204,12 @@ impl Utmpx {
let c_host = CString::new(host).unwrap();
let mut res = ptr::null_mut();
let status = unsafe {
libc::getaddrinfo(c_host.as_ptr(),
ptr::null(),
&hints as *const _,
&mut res as *mut _)
libc::getaddrinfo(
c_host.as_ptr(),
ptr::null(),
&hints as *const _,
&mut res as *mut _,
)
};
if status == 0 {
let info: libc::addrinfo = unsafe { ptr::read(res as *const _) };
@ -255,7 +259,9 @@ impl Iterator for UtmpxIter {
unsafe {
let res = getutxent();
if !res.is_null() {
Some(Utmpx { inner: ptr::read(res as *const _) })
Some(Utmpx {
inner: ptr::read(res as *const _),
})
} else {
endutxent();
None

View file

@ -12,7 +12,10 @@ pub trait ToWide {
fn to_wide(&self) -> Vec<u16>;
fn to_wide_null(&self) -> Vec<u16>;
}
impl<T> ToWide for T where T: AsRef<OsStr> {
impl<T> ToWide for T
where
T: AsRef<OsStr>,
{
fn to_wide(&self) -> Vec<u16> {
self.as_ref().encode_wide().collect()
}
@ -30,6 +33,8 @@ impl FromWide for String {
}
fn from_wide_null(wide: &[u16]) -> String {
let len = wide.iter().take_while(|&&c| c != 0).count();
OsString::from_wide(&wide[..len]).to_string_lossy().into_owned()
OsString::from_wide(&wide[..len])
.to_string_lossy()
.into_owned()
}
}
}