#escaping #string #string-parser

no-std unescape_zero_copy

Unescape strings without allocating memory

10 stable releases

2.2.0 Sep 5, 2024
2.1.1 Aug 3, 2024
2.0.1 Jul 28, 2024
1.2.1 Jul 23, 2024

#221 in Memory management

Download history 206/week @ 2024-07-27 218/week @ 2024-08-03 7/week @ 2024-08-10 40/week @ 2024-08-24 195/week @ 2024-08-31 27/week @ 2024-09-07 24/week @ 2024-09-14 23/week @ 2024-09-21 55/week @ 2024-09-28 105/week @ 2024-10-05 122/week @ 2024-10-12 29/week @ 2024-10-19 78/week @ 2024-10-26 67/week @ 2024-11-02 11/week @ 2024-11-09

206 downloads per month

MIT license

18KB
308 lines

Unescape (zero copy)

Crates.io MIT License

Unescapes strings with C-style escape sequences, written to minimize memory copying. Other crates (e.g. unescaper) like to allocate memory for every string, but most strings don't need any unescaping and so can be returned as-is. This library does that.

It supports custom escape sequence parsers intead of the standard C-style escape sequences as well; an example of this can be found in tests/lua_escapes.rs, using the library to parse Lua escape sequences.

Supports no_std by returning an iterator, or can return a Cow that allocates as needed with the std or alloc feature (std is enabled by default).

Usage

assert_eq!(unescape_zero_copy::unescape_default(r"Hello\x0aworld").unwrap(), "Hello\nworld");

License

The code is released under the MIT license.

No runtime deps