Logo

Programming-Idioms

History of Idiom 212 > diff from v12 to v13

Edit summary for version 13 by programming-idioms.org:
[Rust] +DemoURL

Version 12

2021-02-22, 18:13:35

Version 13

2021-03-25, 17:58:03

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
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).is_dir();
Code
let b: bool = Path::new(path).is_dir();
Doc URL
https://doc.rust-lang.org/std/path/struct.Path.html#method.is_dir
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
Demo URL
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=ee6e73164de4b694a3cd1efe4864c148