just/src/parameter_kind.rs

28 lines
633 B
Rust
Raw Normal View History

use crate::common::*;
/// Parameters can either be…
2021-11-17 00:07:48 -08:00
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")]
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
}
}