| Crates.io | btypes |
| lib.rs | btypes |
| version | 0.7.12 |
| created_at | 2024-11-22 23:58:59.731567+00 |
| updated_at | 2024-11-24 02:18:44.581035+00 |
| description | Better types (BTypes) for when you dislike normal types, I guess. |
| homepage | |
| repository | https://github.com/afemboylol/btypes |
| max_upload_size | |
| id | 1458017 |
| size | 173,253 |
A Rust library providing enhanced types with rich functionality for string manipulation and boolean state management, with more types coming soon.
A feature-rich string type offering:
+ operator* repeats a string N times/ counts occurrences- removes a substring/= keeps only the first occurrenceTwo main categories with multiple capacity options:
BN128: 128-bit capacityBN64: 64-bit capacityBN32: 32-bit capacityBN16: 16-bit capacityBN8: 8-bit capacityBNInf: Effectively infinite capacity using dynamic allocationNums and BitwiseOpsClone/BitwiseOpsCopy traitsFeatures include:
use btypes::bstring::BetterString;
fn main() {
// Basic creation and manipulation
let mut str1 = BetterString::new("Hello, World!");
println!("Original: {}", str1);
println!("Uppercase: {}", str1.to_uppercase());
// Pattern matching and validation
let email = BetterString::new("user@example.com");
println!("Valid email: {}", email.is_valid_email());
// Encoding operations
let encoded = str1.to_base64();
println!("Base64: {}", encoded);
// Pattern matching and replacement
let text = BetterString::new("The quick brown fox");
let matches = text.find_all(r"\w+");
println!("Words: {:?}", matches);
}
use btypes::named_bools::BN128;
fn main() -> anyhow::Result<()> {
let mut state = BN128::new();
// Individual state management
state.set("is_active", true)?;
state.set("is_validated", false)?;
// Mass operations
state.mass_set(4, "flag_{n}", "true,false{r}")?;
// State querying
println!("Active: {}", state.get("is_active")?);
println!("All states: {:?}", state.all()?);
Ok(())
}
use btypes::inf_named_bools::BNInf;
fn main() -> anyhow::Result<()> {
let mut state = BNInf::new();
// Can handle very large numbers of flags
state.mass_set(1000, "flag_{n}", "true,false{r}")?;
// Efficient state management
println!("States: {:?}", state.all()?);
Ok(())
}
bools: Basic boolean typesnamed_bools: Enable named boolean typesstrings: String enhancement functionalityinf_bools: Infinite capacity boolean typesinf_named_bools: Named infinite capacity boolean typesall: Enable all featuresFull working examples available in:
/examples/string_ex.rs: String manipulation demonstrations/examples/bool_ex.rs: Advanced boolean operations/examples/low_cap_bool_ex.rs: Different capacity boolean types/examples/inf_cap_bool_ex.rs: Infinite capacity boolean operationsLicensed under GPL-3.0
Contributions are welcome! Please feel free to submit: