6 releases (1 stable)

new 1.0.0 May 7, 2024
0.2.2 Nov 8, 2023
0.2.1 May 16, 2023
0.1.1 Mar 21, 2023

#558 in Parser implementations

Download history 1/week @ 2024-02-21 6/week @ 2024-02-28 1/week @ 2024-03-13 1/week @ 2024-03-20 8/week @ 2024-03-27 15/week @ 2024-04-03 1/week @ 2024-04-17 51/week @ 2024-04-24

74 downloads per month
Used in whatwg-datetime

MIT/Apache

28KB
445 lines

whatwg-infra

License master docs docs.rs CI codecov

A tiny Rust crate that implements parts of the WHATWG Infra Standard. Specifically, it implements the following:

It exposes a small set of primitives that are useful for parsing text into machine-readable data.

Install

cargo add whatwg-infra

Usage

You can import individual functions:

use whatwg_infra::{
	is_ascii_tab_newline,
	is_c0_control,
	is_c0_control_space,
	is_noncharacter
};

assert!(is_ascii_tab_newline('\t'));
assert!(is_c0_control('\u{0000}'));
assert!(is_c0_control_space('\u{0020}'));

You can also import the traits to get all the functionality, and execute the methods on the types directly.

use whatwg_infra::{InfraScalarValue, InfraStr, InfraUtf16Surrogate};

assert_eq!('a'.is_ascii_tab_newline(), false);
assert_eq!('\u{001E}'.is_c0_control(), true);
assert_eq!('\n'.is_c0_control_space(), true);
assert_eq!('\u{CFFFF}'.is_noncharacter(), true);

no_std

This crate does not depend on libstd, and can be used in #![no_std] environments.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps