mod private
{
#[ allow( unused_imports, clippy ::wildcard_imports ) ]
use crate :: *;
use std ::
{
io,
path :: { Component, Path, PathBuf },
string ::String,
};
pub trait TryIntoPath
{
fn try_into_path( self ) -> Result< PathBuf, io ::Error >;
}
impl TryIntoPath for &str
{
fn try_into_path( self ) -> Result< PathBuf, io ::Error >
{
Ok( PathBuf ::from( self ) )
}
}
impl TryIntoPath for String
{
fn try_into_path( self ) -> Result< PathBuf, io ::Error >
{
Ok( PathBuf ::from( self ) )
}
}
impl TryIntoPath for &Path
{
fn try_into_path( self ) -> Result< PathBuf, io ::Error >
{
Ok( self.to_path_buf() )
}
}
impl TryIntoPath for PathBuf
{
fn try_into_path( self ) -> Result< PathBuf, io ::Error >
{
Ok( self )
}
}
#[ cfg( feature = "path_utf8" ) ]
impl TryIntoPath for &Utf8Path
{
fn try_into_path( self ) -> Result< PathBuf, io ::Error >
{
Ok( self.as_std_path().to_path_buf() )
}
}
#[ cfg( feature = "path_utf8" ) ]
impl TryIntoPath for Utf8PathBuf
{
fn try_into_path( self ) -> Result< PathBuf, io ::Error >
{
Ok( self.as_std_path().to_path_buf() )
}
}
impl TryIntoPath for Component< '_ >
{
fn try_into_path( self ) -> Result< PathBuf, io ::Error >
{
Ok( self.as_os_str().into() )
}
}
impl< T > TryIntoPath for &T
where
T: AsRef< Path >,
{
fn try_into_path( self ) -> Result< PathBuf, io ::Error >
{
Ok( self.as_ref().to_path_buf() )
}
}
}
crate ::mod_interface!
{
orphan use TryIntoPath;
}