Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the error type is particularly relevant here? Do we really need to mandate it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It helps a lot with writing down trait bounds in the user code. See rust-lang/rust#113517 for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To add to that, even with the workaround in the issue above, it does not work when another level is added. That is, if the
foo()in the issue is aserde-standarddeserialize()function, and I want to make a custom deserializer usingserde_withasthere is no way to write trait bounds that would tell the compiler that the returned error is
Display(so that it could be wrapped in theserdeerror).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, if there's a legitimate use case I guess we can include it.
It's just a completely useless error that includes no relevant information, so it's easily handled without bounding on it by using
.ok()or.map_err(...).But if it helps with
serde, I guess that's fine.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is pretty useless, I agree. But if you have a function that is generic on something that's
TryFrom<&[u8]>and you want the error to beDisplay(because it may be useful for some types, so you don't want to discard it), fixing the error in this specific case helps with the bounds. I don't particularly like it either, but unfortunately Rust compiler is currently not smart enough to handle bounds without it. I think it should be pretty harmless, since it's essentially an internal trait that's not supposed to be used outside of the crate.