Optimize away an owned string in path_readlink.

This commit is contained in:
Dan Gohman
2019-09-29 11:52:09 -07:00
committed by Jakub Konka
parent 14bad3cb97
commit 4120d3b44f
2 changed files with 1 additions and 9 deletions

View File

@@ -508,14 +508,6 @@ pub(crate) fn path_from_slice<'a>(s: &'a [u8]) -> Result<&'a str> {
str::from_utf8(s).map_err(|_| Error::EILSEQ)
}
/// Creates owned WASI path from byte vector.
///
/// NB WASI spec requires bytes to be valid UTF-8. Otherwise,
/// `__WASI_EILSEQ` error is returned.
pub(crate) fn path_from_vec<S: Into<Vec<u8>>>(s: S) -> Result<String> {
String::from_utf8(s.into()).map_err(|_| Error::EILSEQ)
}
#[cfg(test)]
mod tests {
use super::*;