hitori_examples/
all_patterns.rs

1//! Sequences of subpatterns can be matched using an all-pattern.
2//! In [hitori] syntax it is represented as a tuple of its subpatterns.
3//!
4//! ```
5#![doc = include_str!("all_patterns/hello.rs")]
6//!
7//! assert!(hitori::string::starts_with(Hello, "hello").is_some());
8//! assert!(hitori::string::starts_with(Hello, "world").is_none());
9//! ```
10//! *equivalent to `hello` in [regex] syntax*
11//!
12//! ### Trailing comma
13//!
14//! The only way to apply attributes such as `#[hitori::capture]` or
15//! `#[hitori::repeat]` to a single character test is by wrapping it
16//! inside of an all-pattern. In that case trailing comma
17//! is **not** optional.
18//!
19//! ```
20#![doc = include_str!("all_patterns/bad_password.rs")]
21//!
22//! assert!(hitori::string::starts_with(BadPassword, "12345").is_some());
23//! assert!(hitori::string::starts_with(BadPassword, "cUFK^06#43Gs").is_none());
24//! ```
25//! *equivalent to `\d{1, 8}` in [regex] syntax*
26//!
27//! ### Empty all-pattern
28//!
29//! An empty all-pattern is always true.
30//!
31//! ```
32#![doc = include_str!("all_patterns/true_.rs")]
33//!
34//! for s in ["Hello, world!", "34", "hitori"] {
35//!     assert!(hitori::string::starts_with(True, s).is_some());
36//! }
37//! ```
38//!
39//! [hitori]: https://docs.rs/hitori
40//! [regex]: https://docs.rs/regex
41
42mod bad_password;
43mod hello;
44mod true_;
45
46pub use bad_password::{BadPassword, BadPasswordCapture};
47pub use hello::{Hello, HelloCapture};
48pub use true_::{True, TrueCapture};