fs_extra icon indicating copy to clipboard operation
fs_extra copied to clipboard

Open to adding builder methods for CopyOptions?

Open CosmicHorrorDev opened this issue 4 years ago • 0 comments
trafficstars

Hello, thanks for the great crate! It really helps cut down on boilerplate for common fs tasks.

I was wondering if you would be open to me adding the builder pattern for fs_extra::dir::CopyOptions and fs_extra::file::CopyOptions? They should both be valid for the full time they're being built so that means it should be rather simple to add and it allows for

use fs_extra::dir;
let mut opts = dir::CopyOptions::new();
opts.overwrite = true;

to be represented as

use fs_extra::dir;
let opts = dir::CopyOptions::new()
    .overwrite(true);

There's not too much difference here, but getting to drop the mut is slightly nicer since it means that refactoring away whatever uses the thing using opts will let the rust compiler pick up that opts is unused in the second and not in the first.

Nothing too major, but might be a bit of a nicety that people are used to. Let me know what you think!

CosmicHorrorDev avatar Mar 11 '21 04:03 CosmicHorrorDev