Skip to content

Conversation

@jon-zu
Copy link

@jon-zu jon-zu commented Oct 31, 2025

This PR introduces:

  • add '_ lifetime to prevent newer compiler warnings
  • unsafe from_raw_parts functions for ArrayVec and ArrayString to allow users to workaround the current const-limitations introduced by the MSRV limit manually
  • new module const_helper providing convienient functions and macros such as array_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant