Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open to adding builder methods for CopyOptions? #43

Open
CosmicHorrorDev opened this issue Mar 11, 2021 · 0 comments
Open

Open to adding builder methods for CopyOptions? #43

CosmicHorrorDev opened this issue Mar 11, 2021 · 0 comments

Comments

@CosmicHorrorDev
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant