Skip to main content

luaur_analysis/functions/
to_string_symbol.rs

1//! Node: `cxx:Function:Luau.Analysis:Analysis/src/Symbol.cpp:21:to_string`
2//! Source: `Analysis/src/Symbol.cpp:21-28` (hand-ported)
3extern crate alloc;
4
5use crate::records::symbol::Symbol;
6use alloc::string::String;
7use luaur_common::macros::luau_assert::LUAU_ASSERT;
8
9/// C++ `std::string toString(const Symbol& name)`.
10pub unsafe fn to_string(name: &Symbol) -> String {
11    if !name.local.is_null() {
12        return core::ffi::CStr::from_ptr((*name.local).name.value)
13            .to_string_lossy()
14            .into_owned();
15    }
16
17    LUAU_ASSERT!(!name.global.value.is_null());
18    core::ffi::CStr::from_ptr(name.global.value)
19        .to_string_lossy()
20        .into_owned()
21}
22
23#[allow(unused_imports)]
24pub use to_string as to_string_symbol;