While browsing the OsString
documentation I found this bit about converting from String
to OsString
:
From a Rust string:
OsString
implementsFrom<String>
, so you can usemy_string.from
to create anOsString
from a normal Rust string.
This didn't look right to me, so I tried the following in on the playground:
use std::ffi::OsString;
fn foo(_: OsString) { }
pub fn main() {
let string = String::new();
foo(string.from());
}
...which failed to compile. However changing the .from()
call to .into()
does work:
use std::ffi::OsString;
fn foo(_: OsString) { }
pub fn main() {
let string = String::new();
foo(string.into());
}
So I think the docs actually meant to say:
From a Rust string:
OsString
implementsFrom<String>
, so you can usemy_string.into()
to create anOsString
from a normal Rust string.
Is there something I'm missing here?