feat: no_std support#5
Merged
brayniac merged 7 commits intoiopsystems:mainfrom Apr 21, 2026
Merged
Conversation
Contributor
|
This mostly looks reasonable. I'll make some changes on top of this before release to avoid the type breakage and the builder pattern breakage. Thanks for the contribution |
6 tasks
brayniac
added a commit
that referenced
this pull request
Apr 21, 2026
* fix: expose Builder::with_clock and add Default for StdClock Builder::with_clock was pub(crate), leaving no_std users without a way to build a Ratelimiter with custom max_tokens or initial_available — the only public no_std constructor was Ratelimiter::with_clock, which takes neither. Make it pub and document it. Also add impl Default for StdClock to satisfy clippy::new_without_default and pair the ergonomic new() constructor with a Default impl. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat: default Clock type parameter to StdClock Make the Clock generic default to StdClock when the std feature is enabled, so callers can name Ratelimiter and Builder without generics in type position — e.g. fn foo(rl: &Ratelimiter) stays valid. Because StdClock itself is gated by #[cfg(feature = "std")], the default can't be expressed unconditionally; the struct declarations for Ratelimiter and Builder are cfg-duplicated with and without the default. The impl blocks are unaffected. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello!
This PR seeks to make the crate
#[no_std]first withstdas the default feature. This is because most of the crate can use the things incorewith the exception ofInstant. This PR makesRatelimitergeneric overClockand providesStdClockfor users that want to usestd. I have made changes to the test as well to not rely onsleep