1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
//! # from_path
//!
//! FromPath trait and implementations.
//!
#[cfg(test)]
#[path = "./from_path_test.rs"]
mod from_path_test;
use std::path::{Path, PathBuf};
/// Defines as path trait.
pub trait FromPath {
/// Converts from a path reference.
fn from_path(path: &Path) -> Self;
}
impl FromPath for String {
fn from_path(path: &Path) -> String {
path.to_string_lossy().into_owned()
}
}
impl FromPath for PathBuf {
fn from_path(path: &Path) -> PathBuf {
path.to_path_buf()
}
}