You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tracing::info!("User {user_id} logged in (org {org_id}).");
154
175
```
155
176
156
-
- Never create temporary variables solely for logging.
177
+
### Numeric Literals
178
+
179
+
- When using a numeric type suffix, you MUST separate the value and suffix with a single underscore.
180
+
- For decimal integer literals with more than three digits (ignoring the sign), you MUST insert an underscore every three digits from the right.
181
+
182
+
Allowed:
183
+
184
+
-`10_f64`.
185
+
-`1_u32`.
186
+
-`0_i64`.
187
+
-`1_000`.
188
+
-`10_000`.
189
+
-`1_000_000`.
190
+
191
+
Forbidden:
192
+
193
+
-`10f64`.
194
+
-`1u32`.
195
+
-`0i64`.
196
+
-`1000`.
197
+
-`10000`.
198
+
-`1000000`.
157
199
200
+
## Guidance (Non-Normative)
158
201
159
-
## Error Wrapping
202
+
Guidance is non-normative. Follow it unless it conflicts with MUST rules, rustfmt output, or explicit requirements.
160
203
161
-
- Add contextual messages at crate or module boundaries, and keep the original error as the source.
162
-
- Use `#[error(transparent)]` only for thin wrappers where this crate adds no context and the upstream
163
-
message is already sufficient for developers.
204
+
### Declaration Order
205
+
206
+
- Inside `#[cfg(test)] mod tests`, prefer `use super::*;` before any other `use` statements.
207
+
208
+
### Imports and Headers
209
+
210
+
- If `crate::prelude::*` is imported, avoid redundant imports.
211
+
212
+
### Logging Rules
213
+
214
+
- Use a short, action-oriented message alongside structured fields.
215
+
- Avoid creating temporary variables solely for logging.
216
+
217
+
### Error Wrapping
218
+
219
+
- Add contextual messages at crate or module boundaries and keep the original error as the source.
220
+
- Use `#[error(transparent)]` only for thin wrappers where this crate adds no context and the upstream message is already sufficient for developers.
164
221
- Prefer short, action-oriented messages that name the operation and include the source error.
165
222
166
-
Example:
223
+
Example (non-normative):
167
224
168
225
```rust
169
226
#[derive(Debug, thiserror::Error)]
170
227
pubenumError {
171
228
#[error(transparent)]
172
229
Utf8(#[from] std::str::Utf8Error),
173
-
230
+
174
231
#[error("Failed to serialize JetStream payload: {0}.")]
175
232
Json(#[from] serde_json::Error),
176
233
}
177
234
```
178
235
179
-
## Borrowing and Ownership
236
+
###Borrowing and Ownership
180
237
181
238
- Prefer `&value` over `.as_ref()` or `.as_str()` where applicable.
182
-
- Avoid `.clone()` unless it is required by ownership or lifetimes.
183
-
- Use `into_iter()` when consuming collections intentionally.
184
-
- Do not use scope blocks solely to end a borrow.
185
-
- When an early release is required, use an explicit drop.
186
-
- When the value is a reference, prefer `let _ = value;` to end the borrow without triggering a
187
-
drop warning.
188
-
- Avoid single-use `let` bindings that only forward a value; inline the expression unless it
189
-
improves readability, error handling, or avoids repeated work.
190
-
191
-
## Numeric Literals
192
-
193
-
- When using a numeric type suffix, always separate the value and suffix with a single underscore:
194
-
- Allowed: `10_f64`, `1_u32`, `0_i64`
195
-
- Forbidden: `10f64`, `1u32`, `0i64`
196
-
197
-
- For decimal integer literals with more than three digits (ignoring the sign), insert an
198
-
underscore every three digits from the right:
199
-
- Allowed: `1_000`, `10_000`, `1_000_000`
200
-
- Forbidden: `1000`, `10000`, `1000000`
239
+
- Avoid `.clone()` unless it is required by ownership or lifetimes.
240
+
- Use `into_iter()` when consuming collections intentionally.
241
+
- Do not use scope blocks solely to end a borrow.
242
+
- When an early release is required, use an explicit `drop`.
243
+
- When the value is a reference, prefer `let _ = value;` to end the borrow without triggering a drop warning.
244
+
- Avoid single-use `let` bindings that only forward a value; inline the expression unless it improves readability, error handling, or avoids repeated work.
201
245
202
-
## Vertical Spacing
246
+
###Vertical Spacing
203
247
204
248
Inside Rust functions:
205
249
206
-
- Same-category statements: no blank lines.
207
-
- Different categories: one blank line.
208
-
- Before the final return or tail expression: exactly one blank line (unless single-expression
209
-
body).
250
+
- Do not insert blank lines within the same statement type.
251
+
- Insert one blank line between different statement types.
252
+
- Insert exactly one blank line before the final return or tail expression, unless the body is a single expression.
253
+
254
+
Treat statements as the same type when they share the same syntactic form or call target, such as:
0 commit comments