4 ms·
No, because propagating an error due to an incorrect static string to the caller is not the right thing to do.
by sanderjd 4y ago
No, because propagating an error due to an incorrect static string to the caller is not the right thing to do.
- Kaze404 4y agoIsn’t the point that in this case it cannot ever error because the string is static?
- sanderjd 4y agoYes, but if you use the `?` operator, as the comment I replied to suggested, then you have to return a `Result`, which the caller has to unwrap themselves or otherwise handle. Except the caller doesn't have this context about how it can't be an error because it's a static string. Propagating the (impossible) error up the call chain is the worst of all worlds in a case like this.