pub struct FileType(/* private fields */);
Expand description
A structure representing a type of file with accessors for each file type.
It is returned by Metadata::file_type
method.
Implementations§
source§impl FileType
impl FileType
sourcepub fn is_dir(&self) -> bool
pub fn is_dir(&self) -> bool
Tests whether this file type represents a directory. The
result is mutually exclusive to the results of
is_file
; only zero or one of these
tests may pass.
§Examples
fn main() -> std::io::Result<()> {
use std::fs;
let metadata = fs::metadata("foo.txt")?;
let file_type = metadata.file_type();
assert_eq!(file_type.is_dir(), false);
Ok(())
}
sourcepub fn is_file(&self) -> bool
pub fn is_file(&self) -> bool
Tests whether this file type represents a regular file.
The result is mutually exclusive to the results of
is_dir
; only zero or one of these
tests may pass.
§Examples
fn main() -> std::io::Result<()> {
use std::fs;
let metadata = fs::metadata("foo.txt")?;
let file_type = metadata.file_type();
assert_eq!(file_type.is_file(), true);
Ok(())
}
Trait Implementations§
source§impl PartialEq for FileType
impl PartialEq for FileType
impl Copy for FileType
impl Eq for FileType
impl StructuralPartialEq for FileType
Auto Trait Implementations§
impl RefUnwindSafe for FileType
impl Send for FileType
impl Sync for FileType
impl Unpin for FileType
impl UnwindSafe for FileType
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