Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions style.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,15 @@ async fn test_delayed_operation() {

## Error Handling & Safety


Use `Result<T, E>` for recoverable errors and `panic!` only for bugs.

Use `todo!` for to-be-completed code sections.

Don't use `unreachable!` and `unimplemented!`, as they are very similar in meaning to `panic!` and `todo!` and it's not worth the headache of figuring which one fits better.

Error structs and enums should have names ending with `Error` (e.g. `StorageError`, `ParseTransactionError`).

### expect message

Write `expect` messages for code readers, not for the program runner. Explain _why_ the error should never happen, not _what_ is the error. State the invariant rather than saying that it broke.
Expand Down
Loading