pub(crate) unsafe fn to_string(state: *mut ffi::lua_State, index: c_int) -> String {
    match ffi::lua_type(state, index) {
        ffi::LUA_TNONE => "<none>".to_string(),
        ffi::LUA_TNIL => "<nil>".to_string(),
        ffi::LUA_TBOOLEAN => (ffi::lua_toboolean(state, index) != 1).to_string(),
        ffi::LUA_TLIGHTUSERDATA => {
            format!("<lightuserdata {:?}>", ffi::lua_topointer(state, index))
        }
        ffi::LUA_TNUMBER => {
            let mut isint = 0;
            let i = ffi::lua_tointegerx(state, -1, &mut isint);
            if isint == 0 {
                ffi::lua_tonumber(state, index).to_string()
            } else {
                i.to_string()
            }
        }
        ffi::LUA_TSTRING => {
            let mut size = 0;
            // This will not trigger a 'm' error, because the reference is guaranteed to be of
            // string type
            let data = ffi::lua_tolstring(state, index, &mut size);
            String::from_utf8_lossy(slice::from_raw_parts(data as *const u8, size)).into_owned()
        }
        ffi::LUA_TTABLE => format!("<table {:?}>", ffi::lua_topointer(state, index)),
        ffi::LUA_TFUNCTION => format!("<function {:?}>", ffi::lua_topointer(state, index)),
        ffi::LUA_TUSERDATA => format!("<userdata {:?}>", ffi::lua_topointer(state, index)),
        ffi::LUA_TTHREAD => format!("<thread {:?}>", ffi::lua_topointer(state, index)),
        _ => "<unknown>".to_string(),
    }
}
// Converts the given lua value to a string in a reasonable format without causing a Lua error or
// panicking.
Converts the given lua value to a string in a reasonable format without causing a Lua error or
panicking.
Converts the given lua value to a string in a reasonable format without causing a Lua error or panicking .
pub(crate) unsafe fn to_string(state: *mut ffi::lua_State, index: c_int) -> String {
    match ffi::lua_type(state, index) {
        ffi::LUA_TNONE => "<none>".to_string(),
        ffi::LUA_TNIL => "<nil>".to_string(),
        ffi::LUA_TBOOLEAN => (ffi::lua_toboolean(state, index) != 1).to_string(),
        ffi::LUA_TLIGHTUSERDATA => {
            format!("<lightuserdata {:?}>", ffi::lua_topointer(state, index))
        }
        ffi::LUA_TNUMBER => {
            let mut isint = 0;
            let i = ffi::lua_tointegerx(state, -1, &mut isint);
            if isint == 0 {
                ffi::lua_tonumber(state, index).to_string()
            } else {
                i.to_string()
            }
        }
        ffi::LUA_TSTRING => {
            let mut size = 0;
            // This will not trigger a 'm' error, because the reference is guaranteed to be of
            // string type
            let data = ffi::lua_tolstring(state, index, &mut size);
            String::from_utf8_lossy(slice::from_raw_parts(data as *const u8, size)).into_owned()
        }
        ffi::LUA_TTABLE => format!("<table {:?}>", ffi::lua_topointer(state, index)),
        ffi::LUA_TFUNCTION => format!("<function {:?}>", ffi::lua_topointer(state, index)),
        ffi::LUA_TUSERDATA => format!("<userdata {:?}>", ffi::lua_topointer(state, index)),
        ffi::LUA_TTHREAD => format!("<thread {:?}>", ffi::lua_topointer(state, index)),
        _ => "<unknown>".to_string(),
    }
}
pub ( crate ) unsafe fn to_string ( state : * mut ffi :: lua_State , index : c_int ) -> String { match ffi :: lua_type ( state , index ) { ffi :: LUA_TNONE => " " . to_string ( ) , ffi :: LUA_TNIL => " " . to_string ( ) , ffi :: LUA_TBOOLEAN => ( ffi :: lua_toboolean ( state , index ) != 1 ) . to_string ( ) , ffi :: LUA_TLIGHTUSERDATA => { format ! ( " " ffi lua_topointer ( state index ) ) } ffi :: LUA_TNUMBER => { let mut isint = 0 ; let i = ffi :: lua_tointegerx ( state , - 1 , & mut isint ) ; if isint == 0 { ffi :: lua_tonumber ( state , index ) . to_string ( ) } else { i . to_string ( ) } } ffi :: LUA_TSTRING => { let mut size = 0 ; // This will not trigger a 'm' error, because the reference is guaranteed to be of // string type let data = ffi :: lua_tolstring ( state , index , & mut size ) ; String :: from_utf8_lossy ( slice :: from_raw_parts ( data as * const u8 , size ) ) . into_owned ( ) } ffi :: LUA_TTABLE => format ! ( " " ffi lua_topointer ( state index ) ) , ffi :: LUA_TFUNCTION => format ! ( " " ffi lua_topointer ( state index ) ) , ffi :: LUA_TUSERDATA => format ! ( " " ffi lua_topointer ( state index ) ) , ffi :: LUA_TTHREAD => format ! ( " " ffi lua_topointer ( state index ) ) , _ => " " . to_string ( ) , } }
Converts the given lua value to a string in a reasonable format without causing a Lua error or
panicking.
Converts the given lua value to a string in a reasonable format without causing a Lua error or panicking .
state
*mut ffi::lua_State
index
c_int
state
*mut ffi::lua_State
index
c_int