#string #macro #literals #string-literal #construct #value #following

the-string-macro

The missing string! macro to construct String value from string literal

1 stable release

1.0.1 Nov 29, 2024

#753 in Rust patterns

Download history 188/week @ 2024-11-25 55/week @ 2024-12-02 21/week @ 2024-12-09

264 downloads per month

MIT license

2KB

the-string-macro

We all have been tired arguing about which of the following is the best practice:

"foo".to_owned()
"foo".to_string()
String::from("foo")
format!("foo")

It's time to finish this...

Usage

the-string-macro = "1"
use the_string_macro::string;

let s = string!("foo");
let props = vec![
    Foo {
        key: string!("key1"),
        value: string!("value1"),
    }
];

No runtime deps