Skip to content

Truly independent web browser

LibWebCommon: Add Infra's is_ascii_whitespace() to Rust

Shannon Booth7690b545d8c7
diff --git a/Libraries/LibWebCommon/Rust/src/infra/character_types.rs b/Libraries/LibWebCommon/Rust/src/infra/character_types.rs
new file mode 100644
index 00000000000..64b0ed2b2fe
--- /dev/null
+++ b/Libraries/LibWebCommon/Rust/src/infra/character_types.rs
@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2022, Linus Groh <[email protected]>
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+// https://infra.spec.whatwg.org/#ascii-whitespace
+pub const fn is_ascii_whitespace(code_point: u32) -> bool {
+ // ASCII whitespace is U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, or U+0020 SPACE.
+ matches!(code_point, 0x09 | 0x0A | 0x0C | 0x0D | 0x20)
+}
diff --git a/Libraries/LibWebCommon/Rust/src/infra/mod.rs b/Libraries/LibWebCommon/Rust/src/infra/mod.rs
new file mode 100644
index 00000000000..0c9b0b2f9c5
--- /dev/null
+++ b/Libraries/LibWebCommon/Rust/src/infra/mod.rs
@@ -0,0 +1,9 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+//! Infra, https://infra.spec.whatwg.org/
+
+pub mod character_types;
diff --git a/Libraries/LibWebCommon/Rust/src/lib.rs b/Libraries/LibWebCommon/Rust/src/lib.rs
index c302808ff3c..21476d2fea6 100644
--- a/Libraries/LibWebCommon/Rust/src/lib.rs
+++ b/Libraries/LibWebCommon/Rust/src/lib.rs
@@ -15,4 +15,5 @@ mod rust_panic;
pub mod fetch;
pub mod html;
+pub mod infra;
pub mod mime_sniff;