There was an error while loading. Please reload this page.
Captures::add
1 parent 579774d commit 20151b0Copy full SHA for 20151b0
1 file changed
mlua_derive/src/chunk.rs
@@ -32,18 +32,12 @@ impl Captures {
32
Self(Vec::new())
33
}
34
35
- pub(crate) fn add(&mut self, token: &Token) -> Capture {
36
- let tt = token.tree();
37
- let key = token.clone();
38
-
39
- match self.0.iter().find(|arg| arg.key() == &key) {
40
- Some(arg) => arg.clone(),
41
- None => {
42
- let arg = Capture::new(key, tt.clone());
43
- self.0.push(arg.clone());
44
- arg
45
- }
+ pub(crate) fn add(&mut self, token: &Token) {
+ if self.0.iter().any(|arg| arg.key() == token) {
+ return;
46
+ let arg = Capture::new(token.clone(), token.tree().clone());
+ self.0.push(arg);
47
48
49
pub(crate) fn captures(&self) -> &[Capture] {
0 commit comments