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
39
40
41
42
43
44
45
46
47
48
49
use FromStr;
use Debug;
use Regex;
/// Parses value with type T from string.
/// ## Example
/// ```
/// use regex::Regex;
/// use std::sync::OnceLock;
/// use crate::bvreader::bv_reader::generic_parser::parse_generic_value;
///
/// static AMP_NUMCHAN_REGEX: OnceLock<Regex> = OnceLock::new();
///
/// fn main() {
/// let input = "
/// A m p l i f i e r S e t u p
/// ============================
/// Number of channels: 71
/// Sampling Rate [Hz]: 500
/// Sampling Interval [µS]: 2000";
///
/// let re = AMP_NUMCHAN_REGEX.get_or_init(|| {
/// Regex::new(r"Number of channels: (\d*)").unwrap()
/// });
///
/// let output = parse_generic_value::<usize>(input, re).unwrap();
/// let expected = 71;
/// assert_eq!(output, expected);
/// }
///
/// ```