diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-12-06 20:43:59 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-12-09 09:30:30 +1100 |
| commit | 08b8ba0a3207b2c5e34cab7f85323908f8bd8b37 (patch) | |
| tree | fa22fbb45c19e5952b131ba91980dfa0befd91e4 | |
| parent | c6bbb376a24c1397ca13078192418ef746382b10 (diff) | |
| download | rust-08b8ba0a3207b2c5e34cab7f85323908f8bd8b37.tar.gz rust-08b8ba0a3207b2c5e34cab7f85323908f8bd8b37.zip | |
Add some useful comments.
| -rw-r--r-- | compiler/rustc_lexer/src/unescape.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/rustc_lexer/src/unescape.rs b/compiler/rustc_lexer/src/unescape.rs index dab656b35f9..5559c03edea 100644 --- a/compiler/rustc_lexer/src/unescape.rs +++ b/compiler/rustc_lexer/src/unescape.rs @@ -7,7 +7,9 @@ use std::str::Chars; #[cfg(test)] mod tests; -/// Errors and warnings that can occur during string unescaping. +/// Errors and warnings that can occur during string unescaping. They mostly +/// relate to malformed escape sequences, but there are a few that are about +/// other problems. #[derive(Debug, PartialEq, Eq)] pub enum EscapeError { /// Expected 1 char, but 0 were found. @@ -73,9 +75,11 @@ impl EscapeError { } } -/// Takes a contents of a literal (without quotes) and produces a -/// sequence of escaped characters or errors. -/// Values are returned through invoking of the provided callback. +/// Takes a contents of a literal (without quotes) and produces a sequence of +/// escaped characters or errors. +/// +/// Values are returned by invoking `callback`. For `Char` and `Byte` modes, +/// the callback will be called exactly once. pub fn unescape_literal<F>(src: &str, mode: Mode, callback: &mut F) where F: FnMut(Range<usize>, Result<char, EscapeError>), |
