#string #line-string #unicode-characters #no-std

no-std str_indices

Count and convert between indexing schemes on string slices

10 releases

0.4.4 Oct 31, 2024
0.4.3 Nov 7, 2023
0.4.2 Oct 18, 2023
0.4.1 Dec 18, 2022
0.1.0 Mar 11, 2022

#59 in Text processing

Download history 16128/week @ 2024-08-17 13353/week @ 2024-08-24 14467/week @ 2024-08-31 14709/week @ 2024-09-07 17578/week @ 2024-09-14 20014/week @ 2024-09-21 17617/week @ 2024-09-28 14741/week @ 2024-10-05 25391/week @ 2024-10-12 16897/week @ 2024-10-19 16259/week @ 2024-10-26 14759/week @ 2024-11-02 12527/week @ 2024-11-09 13610/week @ 2024-11-16 12487/week @ 2024-11-23 15272/week @ 2024-11-30

55,716 downloads per month
Used in 217 crates (6 directly)

MIT/Apache

75KB
1.5K SLoC

Str Indices

Latest Release Documentation

Count and convert between different indexing schemes on utf8 string slices.

The following schemes are currently supported:

  • Chars (Unicode scalar values).
  • UTF16 code units.
  • Lines, with three options for recognized line break characters:
    • Line feed only.
    • Line feed and carriage return.
    • All Unicode line break characters, as specified in Unicode Annex #14.

Feature Flags

The simd feature flag (enabled by default) enables explicit SIMD optimizations on supported platforms. Disabling it will use the fallback scalar code path on all platforms. This feature flag only affects performance, not behavior.

Unsafe Code

Str Indices uses unsafe code for performance optimizations, primarily for SIMD intrinsics. The unsafe code is kept minimal, mostly compartmentalized, and easy to audit. The entire code base is also fuzz tested.

If you would like to run the fuzz testing suite yourself, install Rust nightly and cargo fuzz and run the following command from the repository root:

cargo +nightly fuzz run random_strings

Additional runs of the fuzz testing suite are very much appreciated, as is general auditing of the code base. If you find any unsoundness, please file an issue!

License

This project is licensed under either of

at your option.

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Str Indices by you will be licensed as above, without any additional terms or conditions.

This crate is no-std, doesn't allocate, and has zero dependencies, and aims to remain that way. Please adhere to this in any submitted contributions.

No runtime deps