1pub mod char;
2
3use melodium_core::*;
4use melodium_macro::{check, mel_function, mel_treatment};
5
6#[mel_treatment(
8 input text Stream<string>
9 output matches Stream<bool>
10)]
11pub async fn exact(pattern: string) {
12 while let Ok(text) = text.recv_string().await {
13 check!(
14 matches
15 .send_bool(text.into_iter().map(|txt| txt == pattern).collect())
16 .await
17 );
18 }
19}
20
21#[mel_function]
23pub fn exact(text: string, pattern: string) -> bool {
24 text == pattern
25}
26
27#[mel_treatment(
29 input text Stream<string>
30 output matches Stream<bool>
31)]
32pub async fn starts_with(pattern: string) {
33 while let Ok(text) = text.recv_string().await {
34 check!(
35 matches
36 .send_bool(
37 text.into_iter()
38 .map(|txt| txt.starts_with(&pattern))
39 .collect()
40 )
41 .await
42 );
43 }
44}
45
46#[mel_function]
48pub fn starts_with(text: string, pattern: string) -> bool {
49 text.starts_with(&pattern)
50}
51
52#[mel_treatment(
54 input text Stream<string>
55 output matches Stream<bool>
56)]
57pub async fn ends_with(pattern: string) {
58 while let Ok(text) = text.recv_string().await {
59 check!(
60 matches
61 .send_bool(
62 text.into_iter()
63 .map(|txt| txt.ends_with(&pattern))
64 .collect()
65 )
66 .await
67 );
68 }
69}
70
71#[mel_function]
73pub fn ends_with(text: string, pattern: string) -> bool {
74 text.ends_with(&pattern)
75}