std-function
fs::create_dir: make one directory
Create a single directory, requiring its parent to exist. This example creates a nested directory inside a newly reserved fixture. Run only inside a disposable working directory. The fixture must not already exist. Expected stdout (not executed): true Common mistake: Expecting missing intermediate parents to be created automatically.
Formal Syntax & Structure
rust syntaxrust
fs::create_dir(path) -> io::Result<()>Working Example
Example Snippetrust
fn main() { use std::fs::{self, File, OpenOptions}; use std::io::{Read, Write}; fs::create_dir("bm-fixture").expect("use a fresh disposable directory"); let p = std::path::Path::new("bm-fixture").join("note.txt"); let d = p.with_file_name("child"); fs::create_dir(&d).unwrap(); println!("{}", d.is_dir());}