Skip to content

Commit

Permalink
chore(docs): add note about const strings (#17774)
Browse files Browse the repository at this point in the history
  • Loading branch information
neuronull authored Jun 28, 2023
1 parent ab39c6a commit d7bc531
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ As an additional note, `rustfmt` sometimes can fail to format code within macros
to see such code that doesn't look like it's formatted correctly, you may need to manually tweak it
if `rustfmt` cannot be persuaded to format it correctly for you. :)

### Const strings

When re-typing the same raw string literal more than once, this can lead to typo
errors, especially when names ares similar. In general, when reasonable, it is
preferred to use [Compile-time constants](https://doc.rust-lang.org/std/keyword.const.html)
when dealing with non-dynamic strings. For example, when working with field names
for event metadata.

As this has not always been a consistently enforced code style for the project,
please take the opportunity to update existing raw strings to use constants
when modifying existing code

## Code Organization

Code is primarily split into two main directories: `lib/` and `src/`.
Expand Down
1 change: 1 addition & 0 deletions docs/DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- [Makefile](#makefile)
- [Code style](#code-style)
- [Logging style](#logging-style)
- [Panics](#panics)
- [Feature flags](#feature-flags)
- [Dependencies](#dependencies)
- [Guidelines](#guidelines)
Expand Down

0 comments on commit d7bc531

Please sign in to comment.