Skip to content

Remove SliceConcatExt, add them as methods on [T]. #1141

Open

Description

@bluss

Remove SliceConcatExt, add them as methods on [T].

We don't need extension traits for this anymore.

Activity

  1. gkoz commented on May 31, 2015

    @gkoz

    Related PR: Rename connect to join.

    BTW I'd very much like Iterator to have those methods instead. I know that would be less efficient than the current implementation. Maybe impl Iterator for slice::Iter could still salvage the more efficient implementation.

  2. bluss commented on Jun 12, 2015

    @bluss
    Author

    Moving a method from an unstable trait to an inherent impl is a minor breaking change I guess.

    This quirky stuff compiles because concat is on a prelude trait:

    <_>::concat(&["1", "2"][..])
  3. frewsxcv commented on Sep 30, 2015

    @frewsxcv
    Contributor

    Here's how Servo joins strings. It's nice that it works directly with iterators to avoid unnecessary allocations

  4. gkoz commented on Sep 30, 2015

    @gkoz

    @frewsxcv
    Is push_str in that implementation not performing any reallocations? Ones that SliceConcatExt is avoiding?

  5. bluss commented on Sep 30, 2015

    @bluss
    Author

    Right, the slice version avoids reallocation while building the string by iterating through to sum up the exact capacity needed up front.

  6. frewsxcv commented on Sep 30, 2015

    @frewsxcv
    Contributor

    I meant that if I have some other data structure like a HashSet, I'd have to iterate through all the string and collect them (causing an allocation to occur I think?) before calling join on it

  7. bluss commented on Sep 30, 2015

    @bluss
    Author

    Yes. Notice that servo could use SliceConcatExt's join when it has a slice for a much more efficient join operation. It's only unfortunate that we can't offer both the efficient slice version and the less efficient iterator version in a single method call. Specialization could help.

  8. added
    T-libs-api
    on Aug 29, 2016
  9. added
    T-libs
    and removed
    T-libs-api
    on Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions