fitzgen / fitzgen/inlinable_string

Support missing std `String` methods

Open
#26 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
71
Forks
10
PR merge metrics
No merged PRs in 30d

Description

`String` has some new methods not supported by `inlinable_string::StringExt` trait, and some of them should be implemented using `unsafe` to perform well (for example, `insert_str` and `retain`).

Of course they can be implemented without `unsafe` (and they would be slow).
However, I think `inlinable_string` crate should implement and test them in some way (possibly using `unsafe`), before users try to implement by themselves.
Use of `unsafe` should be gathered to upstream crates as possible, rather than written by every downstream user.

Here is a list of missing methods:

* [ ] [as_mut_str](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.as_mut_str) (since 1.7.0)
* [ ] [as_str](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.as_str) (since 1.7.0)
* [ ] [drain](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.drain) (since 1.6.0)
* [ ] [insert_str](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.insert_str) (since 1.16.0)
* [ ] [into_boxed_str](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.into_boxed_str) (since 1.4.0)
* [ ] [replace_range](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.replace_range) (since 1.6.0)
* [ ] [retain](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.retain) (since 1.26.0)
* [ ] [split_off](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.split_off) (since 1.16.0)

They can be implemented to `InlineString` without breaking changes.
However, adding them to `StringExt` is breaking change, and it is better to be done at once.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the inlinable_string::StringExt trait and InlineString implementation, comparing their existing API with the eight listed std::String methods. Check how current tests cover StringExt and InlineString, then implement and test the missing methods while considering the breaking change of adding them to StringExt and the requested unsafe-performance tradeoffs.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.