You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As discussed in this PR mesalock-linux/mesabox#24. We should use predicate::str::contains(str).from_utf8() to convert Predicate<str> to Predicate<[u8]> for stdout() and stderr() comparison.
It's difficult to find answer in the documentation. There are several reasons:
assert_cmd and predicate's documentation are separated, you should look it back and forth.
The from_utf8() is in the PredicateStrExt trait, and it's difficult to find.
For example, my intuition is that stdout() accept a str like this: stdout("Hello, World!"). But what if I want to check if it contains this str? Then I found that stdout() accept a IntoOutputPredicate<P> actually. Then I switch to read the doc of IntoOutputPredicate and understand str implement this trait. But still, how to check contains? I read the doc of predicate and find out str::contains. The doc doesn't tell me how to use it in assert_cmd, then I'm confused. contains() gives me a ContainsPredicate. However, ContainsPredicate only implements Predicate<str>. At this point, I begin to be impatient and spent a lot of time reading the doc. Finally I find the PredicateStrExt.
This is my first experience of using assert_cmd and predicate. I don't know how to improve the APIs. I think it worth to improve the docs, like giving more examples combining assert_cmd and predicate.
The text was updated successfully, but these errors were encountered:
As discussed in this PR mesalock-linux/mesabox#24. We should use
predicate::str::contains(str).from_utf8()
to convertPredicate<str>
toPredicate<[u8]>
forstdout()
andstderr()
comparison.It's difficult to find answer in the documentation. There are several reasons:
assert_cmd
andpredicate
's documentation are separated, you should look it back and forth.from_utf8()
is in thePredicateStrExt
trait, and it's difficult to find.For example, my intuition is that
stdout()
accept a str like this:stdout("Hello, World!")
. But what if I want to check if it contains this str? Then I found thatstdout()
accept aIntoOutputPredicate<P>
actually. Then I switch to read the doc ofIntoOutputPredicate
and understandstr
implement this trait. But still, how to check contains? I read the doc ofpredicate
and find outstr::contains
. The doc doesn't tell me how to use it inassert_cmd
, then I'm confused.contains()
gives me aContainsPredicate
. However,ContainsPredicate
only implementsPredicate<str>
. At this point, I begin to be impatient and spent a lot of time reading the doc. Finally I find thePredicateStrExt
.This is my first experience of using
assert_cmd
andpredicate
. I don't know how to improve the APIs. I think it worth to improve the docs, like giving more examples combiningassert_cmd
andpredicate
.The text was updated successfully, but these errors were encountered: