Anders429 / Anders429/substring

Support Different Kinds of Substrings

Đang mở
#10 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Rust
Star
11
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

There are different kinds of substrings that can be supported by this library. Currently, the implementation supports substrings with respect to `char`s, but some users will likely want substrings with respect to graphemes instead. Word and sentence substrings could also be supported using the relevant unicode standards.

Altogether, I see the following substring variants being possible:

- CharSubstring: respect to chars, which are unicode scalar values.
- GraphemeSubstring: respect to graphemes (using unicode-segmentation).
- WordSubstring: respect to words (using unicode-segmentation).
- SentenceSubstring: respect to sentences (using unicode-segmentation).
- ByteSubstring: respecting individual bytes (equivalent to slicing the string).

Since we are already looking at a breaking change with #9, the `Substring` trait can be renamed to `CharSubstring` (so there is no ambiguity between substring variants). The unicode-segmentation variants (grapheme, word, and sentence) can be guarded behind a `unicode` feature (or perhaps separate features for each?). The byte variant can be held off on for now, since it really isn't needed and presents issues with properly-formed strings.

This solution will give maximum clarity as to what this crate offers, and will give flexibility for users to choose from the various types of substrings offered.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.