boinkor-net / governor

A rate-limiting library for Rust (f.k.a. ratelimit_meter)
https://github.com/boinkor-net/governor
MIT License
592 stars 46 forks source link

Change `clock: &Clock` parameters to `clock: Clock` and remove `Clock: Clone` #231

Closed max-heller closed 6 months ago

max-heller commented 6 months ago

Currently, RateLimiter constructors take in a reference to a Clock and immediately clone it: https://github.com/boinkor-net/governor/blob/be3ae0878968fd869b17e4fee871127abad5bae5/governor/src/state.rs#L80-L83

The Clone bound on Clock isn't used anywhere else, so the constructors could be changed to take a Clock directly and the Clock: Clone bound could be removed--this would make the API more flexible and allow non-Clone clocks

antifuchs commented 6 months ago

Oh. Oh!! Yes, I love that idea. Do you want to submit a PR for it? (: