Crates.io | stringz-macros |
lib.rs | stringz-macros |
version | 0.2.0 |
source | src |
created_at | 2024-04-22 07:14:50.159342 |
updated_at | 2024-05-27 07:17:44.263336 |
description | Procedural macros implementation of stringz |
homepage | |
repository | https://github.com/NichtsHsu/structz |
max_upload_size | |
id | 1216018 |
size | 3,850 |
Convert strings to types to make it available as generic parameters.
cargo add stringz
For no_std
users:
cargo add stringz --no-default-features
use stringz::{TypedString, string};
fn test_hello<T: TypedString>() {
assert_eq!(T::value(), "hello");
}
test_hello::<string!("hello")>();
The string
macro converts "hello"
to the following tuple type:
(Character<'h'>, Character<'e'>, Character<'l'>, Character<'l'>, Character<'o'>)
Note: The above form is only for ease of understanding, the actual Tuple
type of
tuplez is used.
All generated types are zero-sized types:
use stringz::string;
assert_eq!(std::mem::size_of::<string!("no matter how long it is")>(), 0);