Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(str): Specialized string predicates #35

Merged
merged 5 commits into from
May 10, 2018
Merged

Conversation

epage
Copy link
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
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