pub struct Dir { /* private fields */ }
Implementations
sourceimpl Dir
impl Dir
sourcepub fn read(
path: impl AsRef<Path> + Into<PathBuf>,
filter: impl Fn(&Entry<'_>) -> bool
) -> Result<Arc<Self>, Error>
pub fn read(
path: impl AsRef<Path> + Into<PathBuf>,
filter: impl Fn(&Entry<'_>) -> bool
) -> Result<Arc<Self>, Error>
Read a directory.
Example
let src = Dir::read("src", |e| e.is_dir() || e.path().extension() == Some(OsStr::new("rs"))).unwrap();
for (actual, expected) in src.dirs().into_iter().zip(["cargo", "fs"]) {
assert!(actual.name() == expected);
}
pub fn name(&self) -> &OsStr
pub fn path(&self) -> &Path
pub fn metadata(&self) -> &Metadata
pub fn dirs(&self) -> impl IntoIterator<Item = &Dir> + '_
pub fn files(&self) -> impl IntoIterator<Item = &File> + '_
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Dir
impl Send for Dir
impl Sync for Dir
impl Unpin for Dir
impl UnwindSafe for Dir
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more