Skip to content

Commit

Permalink
Improve Result's Display impl for extension values
Browse files Browse the repository at this point in the history
Previously, the `Display` impl for `vk::Result` did not include handling
for extension values. For example, VK_ERROR_OUT_OF_DATE_KHR would
display simply as "-1000001004". Now, we fall back to the `Debug` impl
of the `Result` if the value is unknown (i.e. from an extension). This
preserves the current nice messages for non-extension values, and the
numeric output for truly unknown values, but displays the enum variant
name (e.g. "ERROR_OUT_OF_DATE")  for extension values.
  • Loading branch information
theo3 committed Apr 26, 2021
1 parent 6a522c8 commit cc37e66
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ash/src/vk/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ impl fmt::Display for Result {
if let Some(x) = name {
fmt.write_str(x)
} else {
self.0.fmt(fmt)
write!(fmt, "{:?}", &self)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,7 @@ pub fn generate_result(ident: Ident, enum_: &vk_parse::Enums) -> TokenStream {
if let Some(x) = name {
fmt.write_str(x)
} else {
self.0.fmt(fmt)
write!(fmt, "{:?}", &self)
}
}
}
Expand Down

0 comments on commit cc37e66

Please sign in to comment.