1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! Span-aware literal types, the [`FromLit`] extraction trait, and the
//! [`ToTokens`] round-trip trait.
//!
//! Each span-aware type bundles a parsed value with its source location so
//! diagnostics can point at the exact literal in the user's code.
//!
//! ## Span-Aware Types
//!
//! | Plain type | Span-aware type | Literal kind |
//! |------------|-----------------|--------------|
//! | `String` | [`LitStr`] | `"..."`, `r#"..."#` |
//! | `i8`–`i128`, `isize`, `usize` | [`LitInt<T>`](LitInt) | `42`, `0xFF`, `0b1010` |
//! | `f32`, `f64` | [`LitFloat<T>`](LitFloat) | `3.14`, `1e10` |
//! | `bool` | [`LitBool`] | `true`, `false` |
//! | `char` | [`LitChar`] | `'a'`, `'\n'` |
//! | `u8` | [`LitByte`] | `b'a'`, `b'\xff'` |
//! | `Vec<u8>` | [`LitByteStr`] | `b"..."`, `br#"..."#` |
//! | `CString` | [`LitCStr`] | `c"..."`, `cr#"..."#` |
//!
//! ## Round-Tripping
//!
//! All span-aware types implement [`ToTokens`], so you can extract, validate,
//! and emit a literal back into your macro output with the original span preserved:
//!
//! ```ignore
//! use litext::literal::{LitStr, ToTokens};
//!
//! let lit: LitStr = extract(input)?;
//! if lit.value().is_empty() {
//! return Err(comperr::error(lit.span(), "string cannot be empty"));
//! }
//! lit.to_token_stream()
//! ```
//!
//! ## See Also
//!
//! - [`FromLit`] for implementing custom literal extraction
//! - [`crate::extract`] for the function that drives extraction
//! - [`crate::litext`] for the macro that wraps it
pub use str::*;
pub use *;
pub use *;