Considering the following code:
for entry in fs::read_dir(".")? {
let path = entry?.path();
if path.is_file() && path.extension() == Some(OsStr::new("txt")) {
println!("found txt file");
}
}
will the OsStr::new("txt")
allocation happen only once, or should I manually instruct the compiler as follows?
let txt = OsStr::new("txt");
for entry in fs::read_dir(".")? {
let path = entry?.path();
if path.is_file() && path.extension() == Some(txt) {
println!("found txt file");
}
}
Are there simple ways to inspect number of memory allocations in Rust? I refer to something similar to the Julia's @time macro
, or anyway providing similar information.
I found a similar question here, but not exactly what I am looking for.
Thanks