Skip to content

Commit d7bc531

Browse files
authored
chore(docs): add note about const strings (#17774)
1 parent ab39c6a commit d7bc531

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

STYLE.md

+12
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ As an additional note, `rustfmt` sometimes can fail to format code within macros
2424
to see such code that doesn't look like it's formatted correctly, you may need to manually tweak it
2525
if `rustfmt` cannot be persuaded to format it correctly for you. :)
2626

27+
### Const strings
28+
29+
When re-typing the same raw string literal more than once, this can lead to typo
30+
errors, especially when names ares similar. In general, when reasonable, it is
31+
preferred to use [Compile-time constants](https://doc.rust-lang.org/std/keyword.const.html)
32+
when dealing with non-dynamic strings. For example, when working with field names
33+
for event metadata.
34+
35+
As this has not always been a consistently enforced code style for the project,
36+
please take the opportunity to update existing raw strings to use constants
37+
when modifying existing code
38+
2739
## Code Organization
2840

2941
Code is primarily split into two main directories: `lib/` and `src/`.

docs/DEVELOPING.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- [Makefile](#makefile)
99
- [Code style](#code-style)
1010
- [Logging style](#logging-style)
11+
- [Panics](#panics)
1112
- [Feature flags](#feature-flags)
1213
- [Dependencies](#dependencies)
1314
- [Guidelines](#guidelines)

0 commit comments

Comments
 (0)