whatwg_infra/lib.rs
1/*!
2A tiny Rust crate that implements parts of the WHATWG Infra Standard. Specifically, it implements the following:
3
4- [4.5. Code points](https://infra.spec.whatwg.org/#code-points)
5- [4.6. Strings](https://infra.spec.whatwg.org/#strings)
6
7It exposes a small set of primitives that are useful for parsing text into machine-readable data.
8
9## Install
10
11```shell
12cargo add whatwg-infra
13```
14
15## Usage
16
17You can import individual functions:
18
19```rust
20use whatwg_infra::{
21 is_ascii_tab_newline,
22 is_c0_control,
23 is_c0_control_space,
24 is_noncharacter
25};
26
27assert!(is_ascii_tab_newline('\t'));
28assert!(is_c0_control('\u{0000}'));
29assert!(is_c0_control_space('\u{0020}'));
30
31```
32
33You can also import the traits to get all the functionality, and execute the methods on the types directly.
34
35```rust
36use whatwg_infra::{InfraScalarValue, InfraStr, InfraUtf16Surrogate};
37
38assert_eq!('a'.is_ascii_tab_newline(), false);
39assert_eq!('\u{001E}'.is_c0_control(), true);
40assert_eq!('\n'.is_c0_control_space(), true);
41assert_eq!('\u{CFFFF}'.is_noncharacter(), true);
42```
43
44## no_std
45
46This crate does not depend on libstd, and can be used in `#![no_std]` environments.
47*/
48#![no_std]
49
50/// Detection of UTF-16 surrogate codepoints for `u16`
51///
52/// This module exposes predicate functions for detecting surrogates,
53/// including trailing and leading surrogates.
54pub mod surrogates;
55pub use crate::surrogates::*;
56
57/// Module for Unicode scalar values
58pub mod scalar;
59pub use crate::scalar::*;
60
61/// Module for Unicode strings
62pub mod strings;
63pub use crate::strings::*;