Rollup merge of #97915 - tbu-:pr_os_string_fmt_write, r=joshtriplett
Implement `fmt::Write` for `OsString` This allows to format into an `OsString` without unnecessary allocations. E.g. ``` let mut temp_filename = path.into_os_string(); write!(&mut temp_filename, ".tmp.{}", process::id()); ```
This commit is contained in:
commit
48cf43b752
1 changed files with 8 additions and 0 deletions
|
@ -643,6 +643,14 @@ impl Hash for OsString {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "os_string_fmt_write", since = "1.64.0")]
|
||||||
|
impl fmt::Write for OsString {
|
||||||
|
fn write_str(&mut self, s: &str) -> fmt::Result {
|
||||||
|
self.push(s);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl OsStr {
|
impl OsStr {
|
||||||
/// Coerces into an `OsStr` slice.
|
/// Coerces into an `OsStr` slice.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue