Skip to content

Commit

Permalink
Add a newline after #[cfg(feature = "std")].
Browse files Browse the repository at this point in the history
And add a space before the `{}` in `Error` impls.

Instead of this:
```rust
      #[cfg(feature = "std")]impl std::error::Error for ErrorCode{}
```

Print this:
```rust
      #[cfg(feature = "std")]
      impl std::error::Error for ErrorCode {}
```

rustfmt can do this too, but we can be slightly prettier by default.
  • Loading branch information
sunfishcode committed Feb 16, 2024
1 parent 1f4ab0f commit d2e949f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/rust/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1031,11 +1031,11 @@ impl InterfaceGenerator<'_> {
self.push_str("}\n");
self.push_str("}\n");
if self.gen.opts.std_feature {
self.push_str("#[cfg(feature = \"std\")]");
self.push_str("#[cfg(feature = \"std\")]\n");
}
self.push_str("impl std::error::Error for ");
self.push_str(&name);
self.push_str("{}\n");
self.push_str(" {}\n");
}
}
}
Expand Down Expand Up @@ -1170,7 +1170,7 @@ impl InterfaceGenerator<'_> {
self.push_str("\n");

if self.gen.opts.std_feature {
self.push_str("#[cfg(feature = \"std\")]");
self.push_str("#[cfg(feature = \"std\")]\n");
}
self.push_str("impl");
self.print_generics(lt);
Expand Down Expand Up @@ -1361,11 +1361,11 @@ impl InterfaceGenerator<'_> {
self.push_str("}\n");
self.push_str("\n");
if self.gen.opts.std_feature {
self.push_str("#[cfg(feature = \"std\")]");
self.push_str("#[cfg(feature = \"std\")]\n");
}
self.push_str("impl std::error::Error for ");
self.push_str(&name);
self.push_str("{}\n");
self.push_str(" {}\n");
} else {
self.print_rust_enum_debug(
id,
Expand Down

0 comments on commit d2e949f

Please sign in to comment.