fredmorcos / throttle_my_fn Goto Github PK
View Code? Open in Web Editor NEWA Rust attribute macro to limit a function's number of runs over a specified period of time
License: MIT License
A Rust attribute macro to limit a function's number of runs over a specified period of time
License: MIT License
Great library! One thing I noticed when implementing this to my project was that the documentation says to just import the throttle_my_fn::throttle;
but actually need to also import add parking_lot
to dependencies and import it because this library itself is not doing that.
#[throttle(1, std::time::Duration::from_millis(1000))]
fn foo0() {}
#[throttle(1, std::time::Duration::from_millis(1000))]
fn foo1(a: i32) {}
#[throttle(1, std::time::Duration::from_millis(1000))]
fn foo2(a: i32, b: i32) {}
First two examples work, but 3rd fails with the following:
error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `b`
--> src/lib.rs:23:21
|
23 | fn foo2(a: i32, b: i32) {}
| - ^ expected one of 8 possible tokens
| |
| help: missing `,`
Not sure why it happens.
Hello, there was a compilation error when using the mut keyword to modify formal parameters...
pub fn my_fn(mut td: TextDisplay, w: i32, h: i32) -> bool {
...
}
The compile time error is as follows:
error: expected expression
130 | pub fn my_fn(mut td: TextDisplay, w: i32, h: i32) -> bool {
| ^^^
Hope to support Mut keyword.
This crate looks really nice. Would it be complex to add a feature to debounce?
So you wait for the X time and run only the last one when the timeout is reached?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.