Skip to main content

luaur_analysis/methods/
to_string_options_to_string_options.rs

1//! Node: `cxx:Method:Luau.Analysis:Analysis/src/ToString.cpp:37:to_string_options_to_string_options`
2//! Source: `Analysis/include/Luau/ToString.h:37-60` (hand-ported)
3
4use crate::records::to_string_name_map::ToStringNameMap;
5use crate::records::to_string_options::ToStringOptions;
6use alloc::vec::Vec;
7use luaur_common::records::dense_hash_map::DenseHashMap;
8
9impl ToStringOptions {
10    /// C++ `ToStringOptions(bool exhaustive = false)` with the in-class
11    /// member initializers from ToString.h:43-59.
12    pub fn to_string_options(exhaustive: bool) -> Self {
13        ToStringOptions {
14            exhaustive,
15            use_line_breaks: false,
16            function_type_arguments: false,
17            hide_table_kind: false,
18            hide_named_function_type_parameters: false,
19            hide_function_self_argument: false,
20            hide_table_alias_expansions: false,
21            use_question_marks: true,
22            ignore_synthetic_name: false,
23            max_table_length: luaur_common::FInt::LuauTableTypeMaximumStringifierLength.get()
24                as usize,
25            max_type_length: luaur_common::FInt::LuauTypeMaximumStringifierLength.get() as usize,
26            composite_types_single_line_limit: 5,
27            name_map: ToStringNameMap {
28                types: DenseHashMap::new(core::ptr::null()),
29                type_packs: DenseHashMap::new(core::ptr::null()),
30            },
31            scope: None,
32            named_function_override_arg_names: Vec::new(),
33        }
34    }
35}
36
37impl Default for ToStringOptions {
38    /// C++ `ToStringOptions{}`.
39    fn default() -> Self {
40        Self::to_string_options(false)
41    }
42}