vec-string-to-static-str
vec-string-to-static-str is a Rust library providing utilities for converting vectors of Strings into vectors of &'static str.
This library includes both safe and unsafe methods for achieving this conversion.
Features
- Safe conversion of
Stringto&'static strwithBox::leak - Unsafe conversion of
Stringto&'static strusingstd::mem::transmute
Usage
Add vec_string_to_static_str to your Cargo.toml:
[]
= "1.0.0"
Make sure to add the "unsafe" feature flag to enable
unsafe_vec_string_to_static_str if needed.
Example
use ;
Safety
- Safe Method: Uses
Box::leakto convertStringto&'static str, which leaks memory. - Unsafe Method: Uses
std::mem::transmuteto extend the lifetime of string slices, which can cause undefined behavior if not used correctly.
License
This project is licensed under the MIT License. See the LICENSE file for details.