Skip to content

chanble/static-str

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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");
}

About

string to static str

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages