predicates-rs
predicates-rs copied to clipboard
feat: Add str::contains_all function
This PR adds the str::contains_all
predicate function. It allows one to check if the input contains all provided needles.
use predicates::prelude::*;
let predicate_fn = predicate::str::contains_all(vec!["One", "Two", "Three"]);
assert_eq!(true, predicate_fn.eval("One Two Three"));
assert_eq!(false, predicate_fn.eval("One Two Four"));
assert_eq!(false, predicate_fn.eval("Four Five Six"));
In your example, shouldn't it be a vec
with multiple strings as predicates, or am I misunderstanding something?
let predicate_fn = predicate::str::contains_all(vec!["One", "Two", "Three"]);
You are absolutely correct. I somehow forgot to add the commas.
EDIT: I added the commas in my comment above and in the doc test in 45d4a17.
If we move forward with this, can you squash your commits?
Yes, I can do that once we are ready with this PR.
Yes, I can do that once we are ready with this PR.
The downside to that is it requires an extra ping-pong between us to get this in, causing more context switches, and being fairly easy to fall through the cracks
The downside to that is it requires an extra ping-pong between us to get this in, causing more context switches, and being fairly easy to fall through the cracks
Can't we just use squash-merge? Then GitHub would do the heavy lifting for us :)
Can't we just use squash-merge? Then GitHub would do the heavy lifting for us :)
Not the most ideal experience and I don't like blindly squashing PRs but only doing it as a last resort because we should preserve multiple commits when they are relevant.
I now squashed all previous commits (Adding the function, updating the docs, and merging changes from main).
I will now continue to work on the unresolved conversations above.