Logo

Programming-Idioms

History of Idiom 212 > diff from v10 to v11

Edit summary for version 11 by robot_rover:
[Rust] exists is for any file, not specifically a directory

Version 10

2020-03-16, 17:16:41

Version 11

2020-07-25, 17:48:32

Idiom #212 Check if folder exists

Set boolean b to true if path exists on the filesystem and is a directory; false otherwise.

Idiom #212 Check if folder exists

Set boolean b to true if path exists on the filesystem and is a directory; false otherwise.

Variables
b,path
Extra Keywords
test whether existence
Extra Keywords
test whether existence
Imports
use std::path::Path;
Imports
use std::path::Path;
Code
let _b: bool = Path::new(path).exists();
Code
let b: bool = Path::new(path).is_dir();
Doc URL
https://doc.rust-lang.org/std/path/struct.Path.html#method.exists
Doc URL
https://doc.rust-lang.org/std/path/struct.Path.html#method.is_dir
Origin
https://stackoverflow.com/questions/32384594/how-to-check-whether-a-path-exists
Origin
https://stackoverflow.com/questions/32384594/how-to-check-whether-a-path-exists