Trait rpf::AsPath [] [src]

pub trait AsPath {
    fn as_path(&self) -> &Path;
    fn as_pathbuf(&self) -> PathBuf;
}

A trait for treating String and str as Path and PathBuf

Required Methods

Returns a borrowed Path

Example

use rpf::AsPath;
use std::path::Path;

let path = "/etc/test/string".as_path().clone();
assert_eq!(path, Path::new("/etc/test/string"));

Returns a PathBuf

Example

use rpf::AsPath;
use std::path::PathBuf;

let pathbuf = "/var/log/test".as_pathbuf();
assert_eq!(pathbuf, PathBuf::from("/var/log/test"));

Implementors