1mod str_replace;
2
3pub use self::str_replace::{ReplaceInput, ReplaceInputConv};
4
5mod str_repeat;
6pub use str_repeat::StrRepeatArgs;
7
8mod str_splice;
9pub use str_splice::{DecomposedString, SplicedStr, StrSplceArgsConv, StrSpliceArgs};
10
11mod str_indexing;
12pub use str_indexing::{IndexValidity, StrIndexArgs, StrIndexArgsConv};
13
14#[cfg(feature = "rust_1_64")]
15mod str_split;
16
17#[cfg(feature = "rust_1_64")]
18pub use str_split::{SplitInput, SplitInputConv};
19
20mod pattern;
21
22use pattern::{Pattern, PatternCtor, PatternNorm};
23
24mod ascii_byte {
25 #[derive(Copy, Clone)]
26 pub struct AsciiByte(u8);
27
28 impl AsciiByte {
29 #[inline(always)]
30 pub const fn new(byte: u8) -> Self {
31 if byte > 127 {
32 let byte: usize = byte as usize;
33 let _: () = [/* byte isn't valid ascii */][byte];
34 loop {}
35 }
36 Self(byte)
37 }
38 #[inline(always)]
39 pub const fn get(self) -> u8 {
40 self.0
41 }
42 }
43}
44pub use ascii_byte::AsciiByte;
45
46// copied from the konst crate, if that implementation is wrong, this needs to be fixed
47const fn bytes_find(left: &[u8], right: &[u8], from: usize) -> Option<usize> {
48 let mut matching = right;
49
50 __for_range! {i in from..left.len() =>
51 match matching {
52 [mb, m_rem @ ..] => {
53 let b = left[i];
54
55 matching = if b == *mb {
56 m_rem
57 } else {
58 match right {
59 // For when the string is "lawlawn" and we are trying to find "lawn"
60 [mb2, m_rem2 @ ..] if b == *mb2 => m_rem2,
61 _ => right,
62 }
63 };
64 }
65 [] => {
66 return Some(i - right.len())
67 }
68 }
69 }
70
71 if matching.is_empty() {
72 Some(left.len() - right.len())
73 } else {
74 None
75 }
76}
77