Skip to content

feat(str): Specialized string predicates#35

Merged
epage merged 5 commits intoassert-rs:masterfrom
epage:specialized
May 10, 2018
Merged

feat(str): Specialized string predicates#35
epage merged 5 commits intoassert-rs:masterfrom
epage:specialized

Conversation

@epage
Copy link
Copy Markdown
Contributor

@epage epage commented May 10, 2018

Including

  • starts_with
  • ends_with
  • contains with optional count

Unfortunately, we can't take pattern, so we're limited to
Into<String>.

For contains to make sense, I fixed #24.

Fixes #25

epage added 5 commits May 9, 2018 13:17
`set` was an implementaton detail of only some of these predicates that
test against collections of data.  The collections can be unordered,
ordered, or hashed.

This also opens the door for more `iter` predicates.

BREAKING CHANGE: `predicates::set` -> `predicates::iter`.
Reducing API footprint in prep for renaming.

BREAKING CHANGE: `predicates::iter::contains_ord` ->
`predicates::iter::contains(...).ord()`
The goal is to make the inention of the functions ore obvious especially
as we add inverses of these.

Fixes assert-rs#24

BREAKING CHANGE: Renamed functions and structs
- `contains` -> `in_iter`
- `contains_hashable` -> `in_hash`
- `ContainsPredicate::ord` -> `ContainsPredicate::sort`
Including
- starts_with
- ends_with
- contains

Unfortunately, we can't take pattern, so we're limited to
`Into<String>`.

The only thing missing to complete assert-rs#25 is to add a `count` to
`contains`.  This would either be a number or a numeric predicate.
This sets a required count for number of matches.

It could be of value to make this accept a predicate.  In that case, for
API convinience, we should probably have a `ToCountPredicate` that is
attached to both `Predicate<usize>` and `usize`.  This would allow
things like `contains("Two").count(predicate::in_iter([3, 4])`.

Fixes assert-rs#25
@epage epage merged commit a3c8d61 into assert-rs:master May 10, 2018
@epage epage deleted the specialized branch May 10, 2018 18:09
takumi-earth pushed a commit to earthlings-dev/predicates-rs that referenced this pull request Jan 27, 2026
 feat(str): Specialized string predicates
epage added a commit to epage/predicates-rs that referenced this pull request Jan 27, 2026
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [actions/checkout](https://redirect.github.com/actions/checkout) |
action | major | `v5` -> `v6` |

---

### Release Notes

<details>
<summary>actions/checkout (actions/checkout)</summary>

### [`v6`](https://redirect.github.com/actions/checkout/compare/v5...v6)

[Compare
Source](https://redirect.github.com/actions/checkout/compare/v5...v6)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 5am on the first day of the
month" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/epage/_rust).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi4xOS45IiwidXBkYXRlZEluVmVyIjoiNDIuMTkuOSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
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.

Specialized string predicates Contains behavior is confusing

1 participant