std-method
DirEntry::metadata: inspect an entry without following links
Inspect attributes of an entry itself rather than its symlink target. Entries can change after enumeration. Use a fresh disposable working directory exclusively controlled by this program. Expected stdout (not executed): 4 Common mistake: Assuming earlier metadata describes a later opened handle.
Formal Syntax & Structure
rust syntaxrust
entry.metadata() -> io::Result<Metadata>Working Example
Example Snippetrust
fn main() { use std::fs::{self, File}; use std::io::{Read, Write}; fs::create_dir("bm-fixture").expect("fresh working directory required"); let p = std::path::Path::new("bm-fixture").join("note.txt"); File::create_new(&p).unwrap().write_all(b"1234").unwrap(); let e = fs::read_dir("bm-fixture").unwrap().next().unwrap().unwrap(); println!("{}", e.metadata().unwrap().len());}