swiftlang / swiftlang/swift-experimental-string-processing

`contains<C>(_:)` does not behave as expected

Open
#694 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
308
Forks
52
Avg merge
12h 45m
Merged PRs (30d)
2

Description

Because this is defined on Collection it is available to all Collection types, not just String. The behavior on other types is odd at best. It isn't even predictable when working with a Set. I think it should either be fixed to behave as expected, or narrowed down to just work on String?

Attached is an example playground to experiment with which demonstrates the issue.

Contains.playground.zip

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the attached Contains.playground.zip and compare contains(_:) behavior across Collection types, especially Set. The issue does not choose between correcting the behavior and restricting the API to String, so completion requires an agreed direction, predictable behavior, and tests for the chosen scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.