#[repr(u8)]pub enum ParamKind {
PositionalOnly = 0,
Normal = 1,
NamedOnly = 2,
Rest = 3,
RestMap = 4,
RestNamed = 5,
}Expand description
How a parameter of a ParamList receives arguments.
The kinds appear in this order in a list: positional-only, normal,
at most one rest (Rest or
RestMap), named-only, at most one
RestNamed. This is HIR’s Param kind set
(specs/HIR.md §10) without the receiver, which is an ordinary
positional parameter at this level.
§Examples
use bytecode_lang::ParamKind;
assert_eq!(ParamKind::Normal.code(), 1);
assert_eq!(ParamKind::RestNamed.to_string(), "rest_named");
assert!(ParamKind::RestMap.is_rest());
assert!(ParamKind::NamedOnly.takes_names());
assert!(!ParamKind::PositionalOnly.takes_names());Variants§
PositionalOnly = 0
Bound by position only (Python’s parameters before /).
Normal = 1
Bound by position or by name (every PHP parameter).
NamedOnly = 2
Bound by name only (Python’s parameters after *).
Rest = 3
Collects the extra positional arguments into a new dyn array
(Python *args).
RestMap = 4
Collects the extra positional arguments into a new dyn map under
the keys 0, 1, ..., and, when the list has no
RestNamed, the unknown named arguments
under their names (PHP ...$args since 8.1).
RestNamed = 5
Collects the unknown named arguments into a new dyn map from name
to value (Python **kwargs).
Implementations§
Source§impl ParamKind
impl ParamKind
Source§impl ParamKind
impl ParamKind
Sourcepub const fn is_rest(self) -> bool
pub const fn is_rest(self) -> bool
Whether the parameter collects arguments into a new container.
§Examples
use bytecode_lang::ParamKind;
assert!(ParamKind::Rest.is_rest());
assert!(!ParamKind::Normal.is_rest());Sourcepub const fn takes_names(self) -> bool
pub const fn takes_names(self) -> bool
Whether a named argument can bind to the parameter by its name.
§Examples
use bytecode_lang::ParamKind;
assert!(ParamKind::Normal.takes_names());
assert!(!ParamKind::Rest.takes_names());