scratch_test_value/
texts.rs1mod nth_letter;
2
3pub use nth_letter::NthLetterOfTextQ;
4
5use crate::{ARc, SValue};
6
7impl SValue {
8 pub fn concat_no_limit(&self, other: &SValue) -> ARc<str> {
9 self.concat(other, usize::MAX).unwrap_or_default()
10 }
11
12 pub fn concat(&self, other: &SValue, max_string_length: usize) -> Option<ARc<str>> {
14 let my_text = self.as_text();
15 let ot_text = other.as_text();
16 if my_text.len() + ot_text.len() > max_string_length {
17 return None;
18 }
19
20 let mut s = my_text.to_string();
21 s += ot_text.as_ref();
22 Some(s.into())
23 }
24
25 pub fn contains_text(&self, maybe_contained: &SValue) -> bool {
28 self.as_text()
29 .to_lowercase()
30 .contains(&maybe_contained.as_text().to_lowercase())
31 }
32
33 pub fn textual_length(&self) -> usize {
35 self.as_text().chars().count()
36 }
37}