diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-11-20 23:32:30 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-11-20 23:32:30 +0100 |
| commit | ddada4509729b0b8dcc394737d7eec588df51040 (patch) | |
| tree | 828a84eea9488f14878bf0ca16ee121e20a9de29 /src/model/func.rs | |
| parent | 46d469f4bee6afd6b0d7dfdb3f095b98b18ac5f9 (diff) | |
Tracepoints for show rules
Diffstat (limited to 'src/model/func.rs')
| -rw-r--r-- | src/model/func.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/model/func.rs b/src/model/func.rs index 15434bbf..21e36784 100644 --- a/src/model/func.rs +++ b/src/model/func.rs @@ -68,9 +68,7 @@ impl Func { /// The number of positional arguments this function takes, if known. pub fn argc(&self) -> Option<usize> { match self.0.as_ref() { - Repr::Closure(closure) => Some( - closure.params.iter().filter(|(_, default)| default.is_none()).count(), - ), + Repr::Closure(closure) => closure.argc(), Repr::With(wrapped, applied) => Some(wrapped.argc()?.saturating_sub( applied.items.iter().filter(|arg| arg.name.is_none()).count(), )), @@ -239,6 +237,15 @@ impl Closure { result } + + /// The number of positional arguments this function takes, if known. + pub fn argc(&self) -> Option<usize> { + if self.sink.is_some() { + return None; + } + + Some(self.params.iter().filter(|(_, default)| default.is_none()).count()) + } } /// A visitor that determines which variables to capture for a closure. |
