BurntSushi / walkdir

Rust library for walking directories recursively.
The Unlicense
1.21k stars 106 forks source link

Example fails to compile with 'cannot use the `?` operator in a function that returns `()` #145

Closed SimplicityGuy closed 3 years ago

SimplicityGuy commented 3 years ago

On https://docs.rs/walkdir/2.3.1/walkdir/, there is an example that is simply:

    for entry in WalkDir::new(start) {
        println!("{}", entry?.path().display());
    }

However, this fails to compile, giving the error:

13 | |         println!("{}", entry?.path().display());
   | |                        ^^^^^^ cannot use the `?` operator in a function that returns `()`
BurntSushi commented 3 years ago

You need to use ? in a function that returns a Result.