diff --git a/single_file_tests/lifecycle_str.rs b/single_file_tests/lifecycle_str.rs new file mode 100644 index 0000000..df82eb6 --- /dev/null +++ b/single_file_tests/lifecycle_str.rs @@ -0,0 +1,12 @@ + + +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()) +} +