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

uprev notify to 5.0.0-pre.16 #182

Merged
merged 2 commits into from
Aug 14, 2022
Merged

uprev notify to 5.0.0-pre.16 #182

merged 2 commits into from
Aug 14, 2022

Conversation

samuelcolvin
Copy link
Owner

@0xpr03
Copy link

0xpr03 commented Aug 14, 2022

Add notify::Config as Config::default() to watcher initialization.
Also PollWatcher now has the default interface, as all watchers now take a Config (with only the pollwatcher config settings currently), thus enabling one config for all possible backends.

(And if you want the debouncer, it is the only way to enable some features on init.)

@codecov
Copy link

codecov bot commented Aug 14, 2022

Codecov Report

Merging #182 (15fa415) into main (6636d3d) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##              main      #182   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines          385       385           
  Branches        81        81           
=========================================
  Hits           385       385           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6636d3d...15fa415. Read the comment docs.

@samuelcolvin
Copy link
Owner Author

Add notify::Config as Config::default() to watcher initialization. Also PollWatcher now has the default interface, as all watchers now take a Config (with only the pollwatcher config settings currently), thus enabling one config for all possible backends.

(And if you want the debouncer, as the only way to enable some features on init.)

Thanks, done I think.

Config::new(delay, compare_contents) would be much more use friendly than Config::default().with_poll_interval(delay), would you consider adding new()?

@0xpr03
Copy link

0xpr03 commented Aug 14, 2022

The idea was to allow extending this in the future. Your idea would break semver (require a major release) if I'd add more settings into the new() call.
Edit: Otherwise I could have just made one struct with pub fields.

@samuelcolvin
Copy link
Owner Author

Ye I see that, rust's lack of default/optional/keyword arguments bites again.

@0xpr03
Copy link

0xpr03 commented Aug 14, 2022

You can actually do

Config {
delay: 1,
..default()
}

But that's cumbersome and doesn't require (AFAIK) you to actually do the default call, so would break semver. (I've got the feeling I'm missing some better option.)

@samuelcolvin
Copy link
Owner Author

You can actually do

Yes, I thought about exactly that, but if you do

let config = Config {
    poll_interval: delay,
    compare_contents: whatever,
    ...Default::default(),
};

(adding the ...Default::default() so new fields don't break the code)

I think clippy would complain that ...Default::default() can be removed.

@samuelcolvin samuelcolvin merged commit 50eb31d into main Aug 14, 2022
@samuelcolvin samuelcolvin deleted the 5.0.0-pre.16 branch August 14, 2022 13:14
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

Successfully merging this pull request may close these issues.

None yet

2 participants