Macro string

Source
macro_rules! string {
    ($name:ident, $doc:expr) => { ... };
}
Expand description

Creates a new type wrapping a String with common methods and trait implementations.

The string! macro generates a new type that wraps a Rust String, automatically implementing common methods and traits. This provides a convenient way to create domain-specific string types with minimal boilerplate.

§Usage

// Define a type for address labels
string!(AddressLabel, "A label for a Zcash address");

// Use the generated type
let label = AddressLabel::from("My Savings".to_string());

§Generated Functionality

The generated type includes conversions to and from standard Rust string types, as well as implementations for common traits like Parse, Debug, Display, Clone, PartialEq, Eq, and Hash.

In the ZeWIF format, this macro is useful for creating strongly-typed string values such as address labels, wallet notes, purpose strings, and other textual metadata associated with addresses and accounts.