1 stable release
Uses new Rust 2024
| 1.0.0 | Jan 20, 2026 |
|---|
#835 in Rust patterns
Used in gf2
19KB
128 lines
Overview
The utilities_rs crate is a small collection of useful Rust traits, types, functions, and macros:
| Module | Description |
|---|---|
stopwatch |
Provides the Stopwatch type that is used to measure the time taken by a code block. |
pretty |
Provides a trait and functions that inject separators into the strings for large numbers to enhance readability. |
repeat |
Provides a macro to create repeated invocations of any macro over a list of arguments. |
-
The
Stopwatchtype provides simple, effective timing for code execution. It measures the elapsed time in seconds from a zero-time, which is set at construction time or by callingStopwatch::reset. The primary goal is ease of use, and the type is kept deliberately simple. Use aStopwatchfor cheap-and-cheerful performance measurement. It is not a replacement for the many more complete but more complex code profiling tools. -
The
Prettytrait andpretty()function inject separators into the string representations of large numbers to enhance readability. For example, the number10000000.1234can be represented as10,000,000.1234or1_0000_0000.1234, depending on the chosen separator and grouping size. -
The
repeat!macro creates repeated invocations of another macro over a list of arguments or pairs of arguments. Rust's declarative macros are often write-once type structures because the syntax used is peppered with parentheses, dollar signs, and if you use repetition, yet more parentheses, asterisks, and plus signs. Therepeat!macro is designed to remove one layer of confusing punctuation.
Installation
To include the utilities_rs crate in your Rust project, add the following line to your Cargo.toml file:
[dependencies]
utilities_rs = "1.0.0"
Copyright and License
Copyright (c) 2025-present Nessan Fitzmaurice.
You can use this software under the MIT License