-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add "Rust's Almost-Rules and Almost-Almost-Rules"
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
title: "Language Design: Rust's Almost-Rules ... – ... and Almost-Almost-Rules" | ||
date: 2024-08-05 | ||
--- | ||
|
||
(Inspired by [Almost Rules](https://matklad.github.io/2022/07/10/almost-rules.html).) | ||
|
||
### Syntax edition | ||
|
||
##### `:` is followed by a type | ||
|
||
- except inside struct initializers, where it is followed by a value | ||
- except function result types, which are preceded by `->` | ||
|
||
##### generics use `<>` | ||
|
||
- except in expression contexts, which uses `::<>` | ||
|
||
##### invocations use `()` | ||
|
||
- except where `{}` or `[]` is used, because "they convey important information" | ||
- except for macro invocations, where `()`, `{}`, `[]` are equivalent and interchangeable | ||
|
||
##### `T {}` initializes a struct | ||
|
||
- except inside an `if`, where `{` starts a branch | ||
|
||
##### Rust has no varargs | ||
|
||
- except for `extern` functions | ||
- except for macros | ||
|
||
##### `let` introduces a binding | ||
|
||
- except in pattern matching, where `let` is implied | ||
- except if the match starts with an uppercase letter, then it refers to an identifier in the outer scope | ||
- except in macro pattern matching, where it is matched verbatim | ||
|
||
##### types with a total order implement `Eq` and `Ord` | ||
|
||
- except `f64` and `f32`, which do not |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters