13 lines
224 B
Rust
13 lines
224 B
Rust
|
|
|
|
fn main() {
|
|
let a = string_to_a_str(&"hello world!");
|
|
println!("{}", a);
|
|
}
|
|
|
|
// SAFE? may these codes cause memory leak?
|
|
fn string_to_a_str(s: &str) -> &'static str {
|
|
Box::leak(s.to_owned().into_boxed_str())
|
|
}
|
|
|