Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn string_to_static_str(s: String) -> &'static str {
- Box::leak(s.into_boxed_str())
- }
- fn main() {
- let s = "hello, world".to_owned();
- let _s: &'static str = string_to_static_str(s);
- println!("{}", _s);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement