forked from mirror/async-std
Implemented PathBuf::as_path
This commit is contained in:
parent
409a10a8b5
commit
1bd17f11f2
1 changed files with 18 additions and 0 deletions
|
@ -10,6 +10,24 @@ pub struct PathBuf {
|
||||||
inner: std::path::PathBuf,
|
inner: std::path::PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PathBuf {
|
||||||
|
/// Coerces to a [`Path`] slice.
|
||||||
|
///
|
||||||
|
/// [`Path`]: struct.Path.html
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use async_std::path::{Path, PathBuf};
|
||||||
|
///
|
||||||
|
/// let p = PathBuf::from("/test");
|
||||||
|
/// assert_eq!(Path::new("/test"), p.as_path());
|
||||||
|
/// ```
|
||||||
|
pub fn as_path(&self) -> &Path {
|
||||||
|
self.inner.as_path().into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<std::path::PathBuf> for PathBuf {
|
impl From<std::path::PathBuf> for PathBuf {
|
||||||
fn from(path: std::path::PathBuf) -> PathBuf {
|
fn from(path: std::path::PathBuf) -> PathBuf {
|
||||||
PathBuf { inner: path }
|
PathBuf { inner: path }
|
||||||
|
|
Loading…
Reference in a new issue