Skip to main content

luaur_analysis/functions/
to_string_constraint_graph.rs

1//! Node: `cxx:Function:Luau.Analysis:Analysis/src/ConstraintGraph.cpp:469:to_string`
2//! Source: `Analysis/src/ConstraintGraph.cpp:469-487` (hand-ported)
3
4use crate::functions::to_string_to_string::to_string_type_pack_id_to_string_options_mut;
5use crate::functions::to_string_to_string_alt_m::to_string_type_id_to_string_options;
6use crate::functions::to_string_to_string_alt_q::to_string_constraint_to_string_options;
7use crate::records::to_string_options::ToStringOptions;
8use crate::type_aliases::constraint_vertex::ConstraintVertex;
9use alloc::format;
10use alloc::string::String;
11
12/// C++ anonymous-namespace `std::string toString(ConstraintVertex vertex)` —
13/// `Luau::visit(overloaded{...}, vertex)` becomes a match over the Variant3.
14pub unsafe fn to_string(vertex: ConstraintVertex) -> String {
15    match vertex {
16        ConstraintVertex::V0(ty) => {
17            let mut opts = ToStringOptions::default();
18            opts.exhaustive = true;
19            format!(
20                "Type {}",
21                to_string_type_id_to_string_options(ty, &mut opts)
22            )
23        }
24        ConstraintVertex::V1(tp) => {
25            let mut opts = ToStringOptions::default();
26            opts.exhaustive = true;
27            format!(
28                "Type pack {}",
29                to_string_type_pack_id_to_string_options_mut(tp, opts)
30            )
31        }
32        ConstraintVertex::V2(c) => {
33            let mut opts = ToStringOptions::default();
34            opts.exhaustive = true;
35            format!(
36                "Cons {}",
37                to_string_constraint_to_string_options(&*c, &mut opts)
38            )
39        }
40    }
41}
42
43#[allow(unused_imports)]
44pub use to_string as to_string_constraint_vertex;