fix(match): fix warnings
This commit is contained in:
parent
e112633509
commit
11fd7ce167
|
@ -91,11 +91,13 @@ where
|
|||
"".to_string()
|
||||
};
|
||||
|
||||
if let Event::Key { key: _, chars } = event {
|
||||
if let Some(chars) = chars {
|
||||
if let Event::Key {
|
||||
key: _,
|
||||
chars: Some(chars),
|
||||
} = event
|
||||
{
|
||||
buffer.push_str(&chars);
|
||||
}
|
||||
}
|
||||
|
||||
// Keep the buffer length in check
|
||||
if buffer.len() > self.max_buffer_size {
|
||||
|
@ -259,13 +261,16 @@ mod tests {
|
|||
RegexMatch::new(2, "multi\\((?P<name1>.*?),(?P<name2>.*?)\\)"),
|
||||
],
|
||||
RegexMatcherOptions {
|
||||
max_buffer_size: 15
|
||||
max_buffer_size: 15,
|
||||
},
|
||||
);
|
||||
assert_eq!(
|
||||
get_matches_after_str("say hello(mary)", &matcher),
|
||||
vec![match_result(1, "hello(mary)", &[("name", "mary")])]
|
||||
);
|
||||
assert_eq!(get_matches_after_str("hello(very long name over buffer)", &matcher), vec![]);
|
||||
assert_eq!(
|
||||
get_matches_after_str("hello(very long name over buffer)", &matcher),
|
||||
vec![]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -203,10 +203,10 @@ impl<Id: Clone> RollingMatcher<Id> {
|
|||
fn is_word_separator(&self, event: &Event) -> bool {
|
||||
match event {
|
||||
Event::Key { key, chars } => {
|
||||
if self.key_word_separators.contains(&key) {
|
||||
if self.key_word_separators.contains(key) {
|
||||
true
|
||||
} else if let Some(char) = chars {
|
||||
self.char_word_separators.contains(&char)
|
||||
self.char_word_separators.contains(char)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
|
|
@ -66,16 +66,14 @@ fn insert_items_recursively<Id>(id: Id, node: &mut MatcherTreeNode<Id>, items: &
|
|||
return;
|
||||
}
|
||||
|
||||
if items.len() == 1 {
|
||||
let item = items.get(0).unwrap();
|
||||
if items.len() == 1 {
|
||||
match item {
|
||||
RollingItem::WordSeparator => {
|
||||
let mut new_matches = Vec::new();
|
||||
if let Some(node_ref) = node.word_separators.take() {
|
||||
if let MatcherTreeRef::Matches(matches) = node_ref {
|
||||
if let Some(MatcherTreeRef::Matches(matches)) = node.word_separators.take() {
|
||||
new_matches.extend(matches);
|
||||
}
|
||||
}
|
||||
new_matches.push(id);
|
||||
node.word_separators = Some(MatcherTreeRef::Matches(new_matches))
|
||||
}
|
||||
|
@ -125,7 +123,6 @@ fn insert_items_recursively<Id>(id: Id, node: &mut MatcherTreeNode<Id>, items: &
|
|||
}
|
||||
}
|
||||
} else {
|
||||
let item = items.get(0).unwrap();
|
||||
match item {
|
||||
RollingItem::WordSeparator => match node.word_separators.as_mut() {
|
||||
Some(MatcherTreeRef::Node(next_node)) => {
|
||||
|
|
|
@ -30,8 +30,11 @@ pub(crate) fn extract_string_from_events(
|
|||
let mut right_separator = None;
|
||||
|
||||
for (i, (event, is_word_separator)) in events.iter().enumerate() {
|
||||
if let Event::Key { key: _, chars } = event {
|
||||
if let Some(chars) = chars {
|
||||
if let Event::Key {
|
||||
key: _,
|
||||
chars: Some(chars),
|
||||
} = event
|
||||
{
|
||||
string.push_str(chars);
|
||||
|
||||
if *is_word_separator {
|
||||
|
@ -43,7 +46,6 @@ pub(crate) fn extract_string_from_events(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(string, left_separator, right_separator)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user