Skip to main content

html_filter/
lib.rs

1#![doc = include_str!("../README.md")]
2#![deny(
3    missing_docs,
4    warnings,
5    deprecated_safe,
6    future_incompatible,
7    keyword_idents,
8    let_underscore,
9    nonstandard_style,
10    refining_impl_trait,
11    rust_2018_compatibility,
12    rust_2018_idioms,
13    rust_2021_compatibility,
14    rust_2024_compatibility,
15    unused,
16    clippy::all,
17    clippy::pedantic,
18    clippy::style,
19    clippy::perf,
20    clippy::complexity,
21    clippy::correctness,
22    clippy::restriction,
23    clippy::nursery,
24    clippy::cargo
25)]
26#![allow(
27    clippy::implicit_return,
28    clippy::question_mark_used,
29    clippy::else_if_without_else,
30    clippy::module_name_repetitions,
31    clippy::missing_inline_in_public_items,
32    clippy::doc_paragraphs_missing_punctuation,
33    reason = "bad lint"
34)]
35#![expect(
36    clippy::single_call_fn,
37    clippy::mod_module_files,
38    clippy::pub_with_shorthand,
39    clippy::pattern_type_mismatch,
40    reason = "style"
41)]
42#![expect(
43    clippy::while_let_on_iterator,
44    reason = "better to understand when the iterator is used after the loop breaks"
45)]
46#![expect(clippy::doc_include_without_cfg, reason = "see issue #13918")]
47#![expect(clippy::blanket_clippy_restriction_lints, reason = "I want them all")]
48#![expect(clippy::multiple_inherent_impl, reason = "useful when lots of methods")]
49#![expect(clippy::pub_use, reason = "better to not break APIs when refactoring")]
50
51// All modules are private to prevent a breaking change after refactoring this
52// crate's structure.
53
54mod errors;
55mod filter;
56mod parse;
57mod types;
58
59pub use crate::filter::types::Filter;
60pub use crate::types::html::Html;
61pub use crate::types::tag::{Attribute, Tag};
62
63/// A const equivalent of the [`Option::unwrap_or`] method.
64const fn unwrap_or(opt: Option<bool>, default: bool) -> bool {
65    match opt {
66        Some(val) => val,
67        None => default,
68    }
69}