Closed robinkrahl closed 4 years ago
tempfile.path() returns a PathBuf, Command::arg accepts something that implements AsRef<OsStr>. As PathBuf already implements AsRef<OsStr>, we can directly pass tempfile.path() to Command::arg instead of converting it to a String.
tempfile.path()
PathBuf
Command::arg
AsRef<OsStr>
String
Ha, the old way is looking pretty silly now. Thank you! I appreciate the explanation too
tempfile.path()
returns aPathBuf
,Command::arg
accepts something that implementsAsRef<OsStr>
. AsPathBuf
already implementsAsRef<OsStr>
, we can directly passtempfile.path()
toCommand::arg
instead of converting it to aString
.