Expand description
§descape
Provides utilities for easily parsing escape sequences in a string via UnescapeExt
, using alloc::borrow::Cow
to only borrow when needed.
This library supports many escape sequences:
\\a
->\x07
\\b
->\x08
\\t
->\x09
\\n
->\x0A
\\v
->\x0B
\\f
->\x0C
\\r
->\x0D
\\e
->\x1B
\\'
->'
\\"
->"
\\`
->`
\\\\
->\\
\\xNN
->\xNN
\\o
->\o
, for all octal digitso
\\oo
->\oo
, for all octal digitso
\\ooo
->\ooo
, for all octal digitso
\\uXXXX
->\u{XXXX}
\\u{HEX}
->\u{HEX}
Along with this, you can define your own custom escape handlers! See UnescapeExt::to_unescaped_with
for more information on that.
This crate supports no-std
.
Optionally, this crate has the std
and core_error
features,
to allow the error type of an invalid escape to implement the Error
trait.
std
uses std::error::Error
, and core_error
depends on core::error::Error
, which is stable on Rust 1.82.0 or greater.
Structs§
- Default
Handler - The default escape sequence handler.
- Invalid
Escape - An error representing an invalid escape sequence in a string.
Traits§
- Escape
Handler - A trait distinguishing an object as a handler for custom escape sequences.
- Unescape
Ext - An extension trait for
&str
to allow parsing escape sequences in strings, only copying when needed.