waterui-str

Crates.iowaterui-str
lib.rswaterui-str
version0.2.0
created_at2025-08-31 14:06:04.372885+00
updated_at2025-09-07 14:17:52.552442+00
descriptionString utilities for WaterUI
homepage
repositoryhttps://github.com/water-rs/waterui
max_upload_size
id1818585
size39,996
Lexo Liu (lexoliu)

documentation

README

waterui-str

A zero-copy string type that can either hold a static reference or a ref-counted owned string.

The Str type provides a unified interface for both static string references and dynamically allocated strings, with automatic reference counting for the latter. This allows for extremely inexpensive passing and cloning of strings throughout your application, as no actual copying of string data occurs when a Str is cloned or passed between functions.

By intelligently managing static references and reference counting, Str combines the best of both worlds - the performance of static references and the flexibility of dynamic strings, all with minimal overhead.

Examples

use waterui_str::Str;

// Create from static string
let s1 = Str::from("static string");

// Create from owned string
let s2 = Str::from(String::from("owned string"));

// Clone is cheap for both variants - just copies a pointer, no string data
let s3 = s1.clone();
let s4 = s2.clone();

// Converting to String
let owned = s2.into_string();

// Static strings don't have reference counts
// reference count is intentionally not exposed

// Owned strings have reference counts
// reference count is intentionally not exposed
Commit count: 183

cargo fmt