How can I list files of a directory in Rust?

后端 未结 3 637
一整个雨季
一整个雨季 2021-02-04 23:21

How can I list all the files of a directory in Rust? I am looking for the equivalent of the following Python code.

files = os.listdir(\'./\')
3条回答
  •  暖寄归人
    2021-02-05 00:16

    You could also use glob, which is expressly for this purpose.

    extern crate glob;
    use self::glob::glob;
    
    let files:Vec = glob("*").collect();
    

提交回复
热议问题