reqwasm icon indicating copy to clipboard operation
reqwasm copied to clipboard

impl PartialEq for reqwasm::http::Method

Open jbg opened this issue 2 years ago • 2 comments

It can be useful to be able to compare the method of a request, e.g. for implementing some common retry logic:

if method == http::Method::GET && RETRYABLE_STATUSES.contains(&status) {
  warn!(
    "fetch failed with {}, will retry in {:?}",
    status, RETRY_DELAY
  );
  // ... retry the request
}

At the moment this fails because there is no PartialEq impl for reqwasm::http::Method, so you have to use matches! which is not so ergonomic when it's an enum with no associated data anyway.

jbg avatar Dec 25 '21 10:12 jbg

Would you like to PR this change?

ranile avatar Dec 25 '21 11:12 ranile

Yup absolutely, just wanted to make sure the impl wasn't left off for a reason. Will send a PR shortly!

jbg avatar Dec 25 '21 11:12 jbg