Skip to content

New str and String API #1253

Closed
Closed
@bluss

Description

@bluss

Proposed new str or String API

  • String::insert_str(&mut self, index: usize, s: &str)
    Just like insert(&mut self, usize, char), but for a string piece. Insertion is inherently inefficient, but this impl will be better than the user having to create an entirely new String.
  • String::splice<R>(&mut self, range: R, s: &str)
    Combine drain and insert_str, allow both removing a range and replacing it with a new string in one operation. Remove range, insert s at range.start.
  • str::repeat(&self, n: usize) -> String
    Convenience to repeat a String. Will size the result correctly up front, so it's both simpler and faster than in-code iterator based solutions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiRelevant to the library API team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions