Expand description
§Utilz
Ergonomic, zero-dependency utility traits for Rust.
This crate provides a collection of extension traits for common Rust types
like Option, Result, Vec, bool, &str, HashMap, and more — to make your
code cleaner, shorter, and more expressive without relying on macros or external dependencies.
§Highlights
-
Log– In-memory logger with filtering support.log_info(),.log_warn(),.print_logs(),.set_up_logger(),.clear()…
-
OptionUtils– Convenient extensions forOption<T>.if_some(),.or_default_with()
-
ResultUtils– Cleaner result handling.if_ok(),.if_err(),.unwrap_or_exit()
-
BoolUtils– Fancy conditionals forbool.toggle(),.not(),.then_val(),.if_true(),.if_false()
-
VecUtils– Push conditionally into vectors.push_if(),.push_if_with()
-
StrUtils– String slice helpers.contains_all(),.contains_any(),.to_title_case()
-
MapUtils– Extensions forHashMap.insert_if(),.get_or()
-
MemUtils– Reflection-like helpers.type_name(),.mem_size(),.view()
-
IdentityUtils– Chainabletap()for debug or logging -
PanicUtils– Exit onNoneorErrwith a message.unwrap_or_exit()
-
DurationUtils– Time formatting helpers.pretty()→"1h 2m 3s"
-
ConvertUtils– ErgonomicTryFromhelpers.to(),.to_or(),.to_result()
-
ClampUtils– Limit a number to a range.clamp_to(min, max)
-
NumberUtils– Integer property checks.is_even(),.is_odd()
-
IteratorUtils– Iterator fallback logic.find_map_or(f, fallback)
§Quick Example
use utilz_rs::*;
let value = Some("hi");
value.if_some(|v| println!("Got: {v}"));
let mut enabled = true;
enabled.toggle();
let name = "hello world";
assert!(name.contains_all(["hello", "world"]));
let duration = std::time::Duration::from_secs(3666);
println!("{}", duration.pretty()); // "1h 1m 6s"§Philosophy
- 🔧 100% Rust standard library
- 🚫 No dependencies
- ✅ Only opt-in trait imports
Use what you want, ignore the rest.
Structs§
Enums§
Traits§
- Bool
Utils - Clamp
Utils - Convert
Utils - Duration
Utils - Pretty-formatting for
Duration. - EqUtils
- Provides sugar methods for comparing values.
- Identity
Utils - Iterator
Utils - Loggable
- MapUtils
- MemUtils
- Reflection helpers: type name and memory size.
- Number
Utils - Option
Utils - Extension methods for
Option<T>. - Panic
Utils - Helpers to panic or exit cleanly with messages.
- Result
Utils - StrUtils
- Extra methods for string slices (
&str). - VecUtils
- Conditional vector push helpers.