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
In the code base we can find multiple occurrences of eg.:
let serde_val = serde_plain::to_string(&iface).expect("Unable to serialize {iface}");
or
let encoded = to_bytes(ctxt,&from_role).expect("Unable to encode {from_role}");
However, .expect() does not support inserting and formatting variables.
Also, inclusion of {err} is unnecessary because expect will append the error automatically:
Note the guidelines on the message itself in the link above.
The expect message should contain the reason or assumption why we expect Result::Ok().
Could we adopt this guidance, to help us or future developers, as when debugging it may help to learn about the rationale why we thought - at time of writing - this was okay.
Thoughts?
The text was updated successfully, but these errors were encountered:
In the code base we can find multiple occurrences of eg.:
or
However,
.expect()
does not support inserting and formatting variables.Also, inclusion of
{err}
is unnecessary becauseexpect
will append the error automatically:See: playground example
And the std rust docs on
Result::expect
"What were they thinking?"
Note the guidelines on the message itself in the link above.
The expect message should contain the reason or assumption why we expect
Result::Ok()
.Could we adopt this guidance, to help us or future developers, as when debugging it may help to learn about the rationale why we thought - at time of writing - this was okay.
Thoughts?
The text was updated successfully, but these errors were encountered: