Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.21 KB | None | 0 0
  1. fn string_to_static_str(s: String) -> &'static str {
  2. Box::leak(s.into_boxed_str())
  3. }
  4.  
  5. fn main() {
  6. let s = "hello, world".to_owned();
  7. let _s: &'static str = string_to_static_str(s);
  8. println!("{}", _s);
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement