@@ -32,7 +32,7 @@ evaluated (primarily) at compile time.
32
32
| ----------------------------------------------| -----------------| -------------| -------------| ---------------------|
33
33
| [ Character] ( #character-literals ) | ` 'H' ` | 0 | All Unicode | [ Quote] ( #quote-escapes ) & [ ASCII] ( #ascii-escapes ) & [ Unicode] ( #unicode-escapes ) |
34
34
| [ String] ( #string-literals ) | ` "hello" ` | 0 | All Unicode | [ Quote] ( #quote-escapes ) & [ ASCII] ( #ascii-escapes ) & [ Unicode] ( #unicode-escapes ) |
35
- | [ Raw] ( #raw-string-literals ) | ` r#"hello"# ` | 0 or more\* | All Unicode | ` N/A ` |
35
+ | [ Raw string ] ( #raw-string-literals ) | ` r#"hello"# ` | 0 or more\* | All Unicode | ` N/A ` |
36
36
| [ Byte] ( #byte-literals ) | ` b'H' ` | 0 | All ASCII | [ Quote] ( #quote-escapes ) & [ Byte] ( #byte-escapes ) |
37
37
| [ Byte string] ( #byte-string-literals ) | ` b"hello" ` | 0 | All ASCII | [ Quote] ( #quote-escapes ) & [ Byte] ( #byte-escapes ) |
38
38
| [ Raw byte string] ( #raw-byte-string-literals ) | ` br#"hello"# ` | 0 or more\* | All ASCII | ` N/A ` |
@@ -88,6 +88,23 @@ evaluated (primarily) at compile time.
88
88
89
89
#### Suffixes
90
90
91
+ A suffix is a non-raw identifier immediately (without whitespace)
92
+ following the primary part of a literal.
93
+
94
+ Any kind of literal (string, integer, etc) with any suffix is valid as a token,
95
+ and can be passed to a macro without producing an error.
96
+ The macro itself will decide how to interpret such a token and whether to produce an error or not.
97
+
98
+ ``` rust
99
+ macro_rules! blackhole { ($ tt : tt ) => () }
100
+
101
+ blackhole! (" string" suffix ); // OK
102
+ ```
103
+
104
+ However, suffixes on literal tokens parsed as Rust code are restricted.
105
+ Any suffixes are rejected on non-numeric literal tokens,
106
+ and numeric literal tokens are accepted only with suffixes from the list below.
107
+
91
108
| Integer | Floating-point |
92
109
| ---------| ----------------|
93
110
| ` u8 ` , ` i8 ` , ` u16 ` , ` i16 ` , ` u32 ` , ` i32 ` , ` u64 ` , ` i64 ` , ` u128 ` , ` i128 ` , ` usize ` , ` isize ` | ` f32 ` , ` f64 ` |
0 commit comments