Skip to content

Conversation

nyurik
Copy link
Contributor

@nyurik nyurik commented Aug 20, 2023

For some reason, fmt::Display for Error uses an unusual form match &self.inner { &Value(ref err) => err.fmt(f), ...}. It seems Value(err) will work just as well.

If this is actually needed, we should add some comment explaining why so

For some reason, `fmt::Display for Error` uses an unusual form `match &self.inner { &Value(ref err) => err.fmt(f), ...}`.  It seems `Value(err)` will work just as well.

If this is actually needed, we should add some comment explaining why so
Copy link
Collaborator

@Thomasdezeeuw Thomasdezeeuw left a comment

Choose a reason for hiding this comment

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

This code was required in older rustc versions where you had to be explicit about whether you owned the variables (err and msg) or had a reference to them (ref err or ref msg). But the compiler got better at determining this for us, so now we can use cleaner code like this.

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.

3 participants