arrayvec
arrayvec copied to clipboard
Add convienient const helper(hidden behind a feature flag)
This PR introduces:
- add
'_lifetime to prevent newer compiler warnings - unsafe
from_raw_partsfunctions forArrayVecandArrayStringto allow users to workaround the current const-limitations introduced by the MSRV limit manually - new module
const_helperproviding convienient functions and macros such asarray_str!, array_bstr!, str, bstr, example:
const S_EMPTY: ArrayString<0> = array_str!("");
assert_eq!(&S_EMPTY, "");
const S_EMPTY_CAP5: ArrayString<5> = array_str!("", 5);
assert_eq!(&S_EMPTY_CAP5, "");
const S1: ArrayString<5> = array_str!("hello");
assert_eq!(&S1, "hello");
const S2: ArrayString<10> = array_str!("hello", 10);
assert_eq!(&S2, "hello");
The const_helper module is hidden behind a non-default const_helper feature flag, which should be only enabled for MSRV 1.63.0 users.
For me this solves the most common pain point with this crate not having functions to construct strings in const context and also allows users to write unsafe helper functions for construction in case that would be required. While still allowing for later version bumps of the MSRV with more constant functionality overall.