pub enum FileName {
Real(PathBuf),
Virtual(Cow<'static, str>),
}Expand description
A FileName represents the name of a logical source code file, while retaining some context about whether that file is a real file on disk, or a “virtual” file, i.e. only exists in memory.
Variants§
Implementations§
Source§impl FileName
impl FileName
Sourcepub fn real<T: Into<PathBuf>>(name: T) -> FileName
pub fn real<T: Into<PathBuf>>(name: T) -> FileName
Creates a new FileName that is intended to represent a real file on disk.
Sourcepub fn virtual_<T: Into<Cow<'static, str>>>(name: T) -> FileName
pub fn virtual_<T: Into<Cow<'static, str>>>(name: T) -> FileName
Creates a new FileName that is intended to represent a virtual file in memory.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Tries to return this filename as a &str, avoiding any allocations
This will only return None if the filename is a path which requires lossy conversion to unicode.
See to_string if you want an infallible conversion to a Rust string, albeit at the cost of an allocation
Trait Implementations§
Source§impl Ord for FileName
impl Ord for FileName
Source§impl PartialOrd for FileName
impl PartialOrd for FileName
impl Eq for FileName
impl StructuralPartialEq for FileName
Auto Trait Implementations§
impl Freeze for FileName
impl RefUnwindSafe for FileName
impl Send for FileName
impl Sync for FileName
impl Unpin for FileName
impl UnwindSafe for FileName
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more