@@ -32,7 +32,7 @@ evaluated (primarily) at compile time.
3232| ----------------------------------------------| -----------------| -------------| -------------| ---------------------|
3333| [ Character] ( #character-literals ) | ` 'H' ` | 0 | All Unicode | [ Quote] ( #quote-escapes ) & [ ASCII] ( #ascii-escapes ) & [ Unicode] ( #unicode-escapes ) |
3434| [ 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 ` |
3636| [ Byte] ( #byte-literals ) | ` b'H' ` | 0 | All ASCII | [ Quote] ( #quote-escapes ) & [ Byte] ( #byte-escapes ) |
3737| [ Byte string] ( #byte-string-literals ) | ` b"hello" ` | 0 | All ASCII | [ Quote] ( #quote-escapes ) & [ Byte] ( #byte-escapes ) |
3838| [ 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.
8888
8989#### Suffixes
9090
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+
91108| Integer | Floating-point |
92109| ---------| ----------------|
93110| ` u8 ` , ` i8 ` , ` u16 ` , ` i16 ` , ` u32 ` , ` i32 ` , ` u64 ` , ` i64 ` , ` u128 ` , ` i128 ` , ` usize ` , ` isize ` | ` f32 ` , ` f64 ` |
0 commit comments