Skip to content

Commit 0384bcb

Browse files
committed
Change Optional to vec
1 parent 40b6926 commit 0384bcb

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

relay-pattern/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ enum Token {
734734
},
735735
/// A list of nested alternate tokens `{a,b}`.
736736
Alternates(Vec<Tokens>),
737-
Optional(Box<Token>),
737+
Optional(Vec<Token>),
738738
}
739739

740740
/// A string literal.

relay-pattern/src/wildmatch.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ where
110110
false
111111
}
112112
Token::Optional(optional) => {
113-
let optional = tokens.with_alternate(t_next, std::slice::from_ref(optional));
113+
let optional = tokens.with_alternate(t_next, &optional[..]);
114114
if is_match_impl::<_, M>(h_current, &optional) {
115115
// There is a match with the optional token, we're done.
116116
return true;
@@ -625,7 +625,7 @@ mod tests {
625625
fn test_optional() {
626626
let mut tokens = Tokens::default();
627627

628-
tokens.push(Token::Optional(Box::new(Token::Literal(literal("foo")))));
628+
tokens.push(Token::Optional(vec![Token::Literal(literal("foo"))]));
629629
assert!(is_match("foo", &tokens, Default::default()));
630630
assert!(is_match("", &tokens, Default::default()));
631631
}
@@ -646,7 +646,7 @@ mod tests {
646646
},
647647
]);
648648

649-
tokens.push(Token::Optional(Box::new(alternates)));
649+
tokens.push(Token::Optional(vec![alternates]));
650650
assert!(is_match("foo", &tokens, Default::default()));
651651
assert!(is_match("bar", &tokens, Default::default()));
652652
assert!(is_match("", &tokens, Default::default()));

0 commit comments

Comments
 (0)