🦀 Tetanus
A rusty extension of the standard library with powerful utilities and ergonomic tools.
Features
- 🎯 Zero-cost abstractions
- 🔒 Thread-safe utilities
- 🚀 Performance-focused data structures
- 📦 Convenient macros
- ⚡ Rate limiting tools
- ⏱️ High-precision timing utilities
Quick Start
Add this to your Cargo.toml
:
[]
= "0.1.0"
Usage Examples
Collection Macros
Create collections with easy-to-read syntax:
use ;
// Create a vector with repeated elements
let zeros = vec_of!; // [0, 0, 0, 0, 0]
// Create a HashMap inline
let config = map! ;
// Create a HashSet inline
let permissions = set!;
Option Extensions
Enhanced Option handling:
use OptionExt;
let value = Some;
assert!; // true
assert!; // false
let doubled = value.map_ref; // Some(84)
Thread-Safe Containers
Easy-to-use atomic containers:
use Atomic;
let counter = new;
let counter_clone = counter.clone;
spawn;
*counter.get_mut += 1;
String Utilities
String manipulation tools:
use StringExt;
let mut s = String from;
s.to_snake_case; // "hello_world"
s.to_camel_case; // "HelloWorld"
s.truncate; // "Hello..."
Vector Extensions
Enhanced vector operations:
use VecExt;
let mut numbers = vec!;
// Remove all even numbers
numbers.remove_all;
// Replace numbers greater than 3 with 0
numbers.replace_all;
// Insert maintaining sort order
numbers.insert_sorted;
Ring Buffer
Fixed-size circular buffer:
use RingBuffer;
let mut buffer = new;
buffer.push;
buffer.push;
buffer.push;
buffer.push; // Automatically removes 1
assert_eq!;
Rate Limiter
Token bucket rate limiting:
use RateLimiter;
let mut limiter = new;
if limiter.try_acquire
Timing Utilities
High-precision timing tools:
use ;
// Simple timer
let timer = new;
// ... do work ...
println!;
// Stopwatch for multiple measurements
let mut sw = new;
// ... do work ...
let split1 = sw.split;
// ... do more work ...
let split2 = sw.split;
println!;
Function Memoization
Cache function results automatically:
use memoize;
memoize!
// First call computes the result
let result1 = fib; // Computed
// Subsequent calls use cached result
let result2 = fib; // Retrieved from cache
Performance
Tetanus is designed with performance in mind:
- Zero-cost abstractions where possible
- Minimal memory usage
- Cache-friendly data structures
- Minimal runtime overhead
Contributing
We welcome contributions! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Special thanks to:
- The Rust community for inspiration
- Contributors and users for feedback and suggestions
- Various Rust crates that influenced the design
Made with ❤️ by the Tetanus team