fix(dynamic string): crash when last segment is static and a single char

Resolves #117.
This commit is contained in:
Jake Stanger
2023-04-22 16:29:54 +01:00
parent 236bb09170
commit 2c88c99cb6

View File

@@ -88,9 +88,13 @@ impl DynamicString {
let mut chars = input.chars().collect::<Vec<_>>();
while !chars.is_empty() {
let char_pair = &chars[..=1];
let char_pair = if chars.len() > 1 {
Some(&chars[..=1])
} else {
None
};
let (token, skip) = if let ['{', '{'] = char_pair {
let (token, skip) = if let Some(['{', '{']) = char_pair {
const SKIP_BRACKETS: usize = 4; // two braces either side
let str = chars