Skip to content

binary_search methods should use Borrow #32822

Closed
@osa1

Description

@osa1

binary_search() takes a reference of the element instead of using Borrow instances. This is causing problems:

  1. &String doesn't make any sense. I should be able to just use &s where s is a String to search in a Vec<String>.
  2. Current API sometimes causes redundant allocations (e.g. when I have a &str at hand, I need to allocate a String)
  3. API is inconsistent in that some other containers use Borrow for this purpose. E.g. HashMap. As a guideline, I think lookup functions of containers should just use Borrow always.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-help-wantedCall for participation: Help is requested to fix this issue.P-mediumMedium priorityT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions