Initializes the console specification parser from `s`. `s` *must* not be empty. The caller must supply, at least, a default console driver name if the user did not specify any console flag.
(s: &'a str)
| 124 | /// `s` *must* not be empty. The caller must supply, at least, a default console driver name |
| 125 | /// if the user did not specify any console flag. |
| 126 | pub fn init(s: &'a str) -> Self { |
| 127 | assert!(!s.is_empty()); |
| 128 | |
| 129 | let (driver, rest) = s.split_once(':').unwrap_or((s, "")); |
| 130 | |
| 131 | let mut flags = HashSet::default(); |
| 132 | let mut keyed_flags = HashMap::default(); |
| 133 | for pair in rest.split(',') { |
| 134 | if pair.is_empty() { |
| 135 | continue; |
| 136 | } |
| 137 | |
| 138 | match pair.split_once('=') { |
| 139 | None => { |
| 140 | let _exists = flags.insert(pair); |
| 141 | } |
| 142 | Some((k, v)) => { |
| 143 | let _old = keyed_flags.insert(k, v); |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | Self { driver, flags, keyed_flags } |
| 149 | } |
| 150 | |
| 151 | /// Queries whether the boolean `flag` is in the specification or not. |
| 152 | /// |