Description
The documentation of From<String>
for OsString
reads
Converts a
String
into aOsString
.The conversion copies the data, and includes an allocation on the heap.
The implementation is platform-specific, but from a quick glance none of the implementations I looked at does seem to actually copy the data.
The documentation of From<String>
for PatBbuf
reads
Converts a
String
into aPathBuf
This conversion does not allocate or copy memory.
It is implemented using OsString::from::<String>
:
fn from(s: String) -> PathBuf {
PathBuf::from(OsString::from(s))
}
So clearly something is off here. Even when all current implementations of the String
to OsString
conversion avoid copying, the documentation does not necessarily need to commit to this property, but neither should it state that the implementation allocates and copies if it actually doesn't.