Skip to content

Commit 3157ae6

Browse files
committed
feat: add support for variadic parameters
Signed-off-by: azjezz <azjezz@protonmail.com>
1 parent 7b506f9 commit 3157ae6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/parameter.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct Parameter {
1414
pub default: Option<Value>,
1515
pub modifiers: Vec<Modifier>,
1616
pub visibility: Option<VisibilityModifier>,
17+
pub variadic: bool,
1718
}
1819

1920
impl Parameter {
@@ -25,6 +26,7 @@ impl Parameter {
2526
modifiers: vec![],
2627
attributes: vec![],
2728
visibility: None,
29+
variadic: false,
2830
}
2931
}
3032

@@ -40,6 +42,12 @@ impl Parameter {
4042
self
4143
}
4244

45+
pub fn variadic(mut self) -> Self {
46+
self.variadic = true;
47+
48+
self
49+
}
50+
4351
pub fn default<T: Into<Value>>(mut self, default: T) -> Self {
4452
self.default = Some(default.into());
4553

@@ -109,6 +117,10 @@ impl Generator for Parameter {
109117
code.push_str(&format!("{} ", data_type.generate(indentation, level)));
110118
}
111119

120+
if self.variadic {
121+
code.push_str("...");
122+
}
123+
112124
code.push_str(&format!("${}", &self.name));
113125

114126
if let Some(default) = &self.default {

0 commit comments

Comments
 (0)