Skip to content

Remove useless Result#1022

Merged
sgrif merged 1 commit into
mainfrom
sg-yeet-to-bytes-result
May 28, 2026
Merged

Remove useless Result#1022
sgrif merged 1 commit into
mainfrom
sg-yeet-to-bytes-result

Conversation

@sgrif
Copy link
Copy Markdown
Contributor

@sgrif sgrif commented May 28, 2026

Our ToBytes trait returns a Result instead of just Bytes. This is a reasonable forward looking decision, except not a single impl anywhere in the code base ever returns an error. And it's a good thing they don't, because the vast majority of the code which calls this method doesn't handle the error. It just unwraps.

If it weren't for the dozens of unwraps everywhere, I would actually be in favor of leaving the Result there if we thought we might conceivably return an error in the future. But since we're not handling the errors, better to just get rid of it entirely.

Our `ToBytes` trait returns a `Result` instead of just `Bytes`. This is
a reasonable forward looking decision, except not a single impl anywhere
in the code base ever returns an error. And it's a good thing they
don't, because the vast majority of the code which calls this method
doesn't handle the error. It just unwraps.

If it weren't for the dozens of unwraps everywhere, I would actually be
in favor of leaving the Result there if we thought we might conceivably
return an error in the future. But since we're not handling the errors,
better to just get rid of it entirely.
Copy link
Copy Markdown
Collaborator

@levkk levkk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@sgrif sgrif merged commit 09e1a8d into main May 28, 2026
24 checks passed
@sgrif sgrif deleted the sg-yeet-to-bytes-result branch May 28, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants