Function vec_string_to_static_str

Source
pub fn vec_string_to_static_str(strings: &Vec<String>) -> Vec<&'static str>
Expand description

Converts a vector of Strings into a vector of &'static str.

This function leaks memory as it uses Box::leak to create static string slices from the input strings. Use with caution.

§Arguments

  • strings - A vector of Strings to be converted.

§Returns

A vector of &'static str references to the input strings.

§Example

use vec_string_to_static_str::vec_string_to_static_str;

let strings = vec![String::from("hello"), String::from("world")];
let static_strs = vec_string_to_static_str(&strings);
assert_eq!(static_strs, vec!["hello", "world"]);