1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use super::StrHelper;
impl StrHelper {
/// get '''String''' version of helper.
pub fn to_string(&self) -> String {
(*self.string).to_string()
}
/// get '''&str''' version of helper.
pub fn as_str(&self) -> &str {
self.string.as_str()
}
/// get '''Vec<char>''' version of helper.
pub fn as_chars(&self) -> Vec<char> {
self.string.chars().collect::<Vec<char>>()
}
/// get element location status in string.
///
/// # Example:
/// ```
/// #[macro_use] extern crate std_helper;
/// use std_helper::StrHelper;
///
/// let helper = str!("Hi!");
/// assert_eq!(helper.contains("Hi"), true);
/// assert_eq!(helper.contains("crab"), false);
/// ```
pub fn contains(&self, pat: &str) -> bool {
self.string.contains(pat)
}
/// get '''Vec<char>''' version of other '''&str'''.
pub fn other_as_chars(value: &str) -> Vec<char> {
value.to_string().chars().collect::<Vec<char>>()
}
}