static-str

Crates.iostatic-str
lib.rsstatic-str
version0.2.0
sourcesrc
created_at2021-09-16 14:48:13.58768
updated_at2022-02-18 06:32:09.030192
descriptionconvert a string into a static str
homepagehttps://github.com/chanble/static-str
repositoryhttps://github.com/chanble/static-str
max_upload_size
id452293
size2,983
chanble (chanble)

documentation

README

rust string to &'static str

how-to-convert-a-string-into-a-static-str

copy form here(how-to-convert-a-string-into-a-static-str)

cannot return reference to temporary value

usage:

use static_str::to_str;

fn main() {
    let option_value = Some(123);
    let v = option_value.map_or("", |v| to_str(v.to_string()));
    assert_eq!(v, "123");
}

Commit count: 5

cargo fmt