Skip to content

Commit acc09b8

Browse files
committed
print OsString without using unwrap()
use to_string_lossy() instead
1 parent 8109a92 commit acc09b8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/process.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ impl Default for Cmd {
274274

275275
impl Cmd {
276276
pub fn add_arg(mut self, arg: OsString) -> Self {
277-
let arg_str = arg.clone().into_string().unwrap();
277+
let arg_str = arg.to_string_lossy().to_string();
278278
if self.args.is_empty() {
279279
let v: Vec<&str> = arg_str.split('=').collect();
280280
if v.len() == 2 && v[0].chars().all(|c| c.is_ascii_alphanumeric() || c == '_') {
@@ -354,7 +354,7 @@ impl Cmd {
354354
args: self
355355
.args
356356
.into_iter()
357-
.map(|s| s.into_string().unwrap())
357+
.map(|s| s.to_string_lossy().to_string())
358358
.collect(),
359359
vars: self.vars,
360360
current_dir: if current_dir.as_os_str().is_empty() {
@@ -578,7 +578,7 @@ impl CmdString {
578578
}
579579
impl fmt::Display for CmdString {
580580
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
581-
f.write_str(&self.0.to_str().unwrap().to_string())
581+
f.write_str(&self.0.to_string_lossy())
582582
}
583583
}
584584

0 commit comments

Comments
 (0)