From a7db8abab7ff04f3e9b7cb7013107dcf37de8687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Sun, 10 Jan 2021 17:47:12 +0200 Subject: Use T! for bool keywords --- docs/dev/style.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'docs') diff --git a/docs/dev/style.md b/docs/dev/style.md index 67cbc6744..7481f8008 100644 --- a/docs/dev/style.md +++ b/docs/dev/style.md @@ -643,6 +643,27 @@ assert!(x >= lo && x <= hi>); **Rationale:** Less-then comparisons are more intuitive, they correspond spatially to [real line](https://en.wikipedia.org/wiki/Real_line). +## Token names + +Use `T![foo]` instead of `SyntaxKind::FOO_KW`. + +```rust +// GOOD +match p.current() { + T![true] | T![false] => true, + _ => false, +} + +// BAD + +match p.current() { + SyntaxKind::TRUE_KW | SyntaxKind::FALSE_KW => true, + _ => false, +} +``` + +**Rationale:** The macro uses the familiar Rust syntax, avoiding ambiguities like "is this a brace or bracket?". + ## Documentation For `.md` and `.adoc` files, prefer a sentence-per-line format, don't wrap lines. -- cgit v1.2.3