Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement functionality present on String and SmallVec #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

daboross
Copy link

This adds a large amount of functionality to SmallString.

I've found the library very useful, so I thought this would be a good way to contribute back.

Most methods which make sense from String and SmallVec are now implemented on SmallString.

This PR:

  • removes default size = [u8; 8] to match behavior of SmallVec
  • implements many methods available on SmallVec but not SmallString
  • implements AsMut without feature gate and without requiring rust 1.20+
  • implements Extend efficiently with pre-reserved capacity
  • re-implements FromIterator more simply
    • the previous FromIterator implementation worked well and was efficient, but it's possible to achieve the same result without creating a whole struct implementing Iterator. The new behavior matches String::from_iterator.
  • updates smallvec crate dependency to achieve full functionality
  • implements many more traits which can be implemented
  • implements some From implementations more efficiently using direct byte-for-byte copies rather than collect() on an iterator.
  • bumps version to '0.2.0' to prepare for release.

Fixes #1, supersedes #2, #3.

To clarify: this is for methods which are present on both, not things
unique to one or the other. It wouldn't make sense to support set_len
like SmallVec::set_len, or as_mut_vec like String::as_mut_vec.

This PR:
- removes default size = [u8; 8] to match behavior of `SmallVec`
- implements many methods available on `SmallVec` but not `SmallString`
- implements `AsMut` without feature gate and without requiring rust
  1.20+
- implements `Extend` efficiently with pre-reserved capacity
- re-implements `FromIterator` more simply
  - the previous `FromIterator` implementation worked well and was
    efficient, but it's possible to achieve the same result without
    creating a whole struct implementing Iterator.
- updates `smallvec` crate dependency to achieve full functionality
- implements many more traits which can be implemented
- implements some From implementations more efficiently using direct
  byte-for-byte copies rather than `collect()` on an iterator.

Closes jFransham#1.
Closes jFransham#2.
Closes jFransham#3.
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