Trait typed_path::TryAsRef

source ·
pub trait TryAsRef<T: ?Sized> {
    fn try_as_ref(&self) -> Option<&T>;
}
Expand description

Interface to try to perform a cheap reference-to-reference conversion.

Required Methods§

Implementations on Foreign Types§

Attempts to convert a std::path::Path into a Path, returning a result containing the new path when successful

Examples
use std::path::Path;
use typed_path::{TryAsRef, UnixPath};

let std_path = Path::new("/path/to/file.txt");
let unix_path: &UnixPath = std_path.try_as_ref().unwrap();

Implementors§