Skip to main content

luaur_analysis/records/
inference_pack.rs

1//! Source: `Analysis/include/Luau/ConstraintGenerator.h:49-61` (hand-ported)
2use crate::type_aliases::refinement_id_refinement::RefinementId;
3use crate::type_aliases::type_pack_id::TypePackId;
4use alloc::vec::Vec;
5
6#[derive(Debug, Clone)]
7pub struct InferencePack {
8    pub tp: TypePackId,
9    pub refinements: Vec<RefinementId>,
10}
11
12impl InferencePack {
13    // C++ `InferencePack() = default;` with `TypePackId tp = nullptr;`.
14    pub fn inference_pack() -> Self {
15        InferencePack {
16            tp: core::ptr::null(),
17            refinements: Vec::new(),
18        }
19    }
20
21    // C++ `explicit InferencePack(TypePackId tp, const std::vector<RefinementId>& refinements = {})`.
22    pub fn inference_pack_type_pack_id_vector_refinement_id(
23        tp: TypePackId,
24        refinements: Vec<RefinementId>,
25    ) -> Self {
26        InferencePack { tp, refinements }
27    }
28}