just/src/parameter_kind.rs
Richard Berry 1ff619295c
Add variadic parameters that accept zero or more arguments (#645)
Add "star" variadic parameters that accept zero or more arguments,
distinguished with a `*` in front of the parameter name.
2020-06-13 01:49:13 -07:00

27 lines
586 B
Rust

use crate::common::*;
/// Parameters can either be…
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub(crate) enum ParameterKind {
/// …singular, accepting a single argument
Singular,
/// …variadic, accepting one or more arguments
Plus,
/// …variadic, accepting zero or more arguments
Star,
}
impl ParameterKind {
pub(crate) fn prefix(self) -> Option<&'static str> {
match self {
Self::Singular => None,
Self::Plus => Some("+"),
Self::Star => Some("*"),
}
}
pub(crate) fn is_variadic(self) -> bool {
self != Self::Singular
}
}