static-str 0.2.0

convert a string into a static str
Documentation
  • Coverage
  • 25%
    1 out of 4 items documented1 out of 3 items with examples
  • Size
  • Source code size: 2.51 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.05 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • chanble/static-str
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • chanble

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