Cyrup Sugars
Syntactic sugar utilities for Rust - collections, async patterns, and macros.
This crate provides ergonomic utilities organized into feature-gated modules:
Features
collections- Enhanced collection types likeZeroOneOrMany,OneOrMany, andByteSizeasync- Async utilities with the "always unwrapped" pattern usingAsyncTaskandAsyncStreammacros- Convenient macros for collections and async operationshashbrown-json- 🔥 Amazing hashbrown HashMap macros with full JSON object supportgix-interop- Git object ID optimized hash tables
Example
use ByteSizeExt;
use ;
// Ergonomic byte sizes
let cache_size = 512.mb;
println!;
// Type-safe async operations (no raw Results allowed)
let task = from_value;
// let bad_task = AsyncTask::from_value(Ok(42)); // Compile error!
🔥 Hashbrown JSON Syntax (with hashbrown-json feature)
use cyrup_sugars::collections::{ZeroOneOrMany, OneOrMany};
use cyrup_sugars::macros::hashbrown::hash_map;
use serde_json;
// Semantic JSON mapping with blazing fast hashbrown
let config = hash_map! {
"servers" => ZeroOneOrMany::many(vec!["api.com", "db.com"]),
"endpoints" => OneOrMany::one("primary.api.com")
};
let json = serde_json::to_string_pretty(&config)?;
// Flexible deserialization - handles null, single values, or arrays
let from_null: ZeroOneOrMany<String> = serde_json::from_str("null")?;
let from_single: ZeroOneOrMany<String> = serde_json::from_str(r#""hello""#)?;
let from_array: ZeroOneOrMany<String> = serde_json::from_str(r#"["hello", "world"]"#)?;