Implement/Derive `Debug` for Lua and few other structs

This commit is contained in:
Alex Orlenko 2021-05-03 13:05:43 +01:00
parent 108682cc71
commit 64346ce56c
3 changed files with 11 additions and 1 deletions

View File

@ -2,6 +2,7 @@ use std::any::TypeId;
use std::cell::{RefCell, UnsafeCell};
use std::collections::{HashMap, HashSet};
use std::ffi::CString;
use std::fmt;
use std::marker::PhantomData;
use std::os::raw::{c_char, c_int, c_void};
use std::panic::resume_unwind;
@ -88,6 +89,7 @@ struct MemoryInfo {
/// More information can be found in the Lua 5.x [documentation].
///
/// [documentation]: https://www.lua.org/manual/5.4/manual.html#2.5
#[derive(Clone, Copy, Debug)]
pub enum GCMode {
Incremental,
/// Requires `feature = "lua54"`
@ -128,6 +130,12 @@ impl Drop for Lua {
}
}
impl fmt::Debug for Lua {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Lua({:p})", self.state)
}
}
impl Lua {
/// Creates a new Lua state and loads the **safe** subset of the standard libraries.
///
@ -1942,7 +1950,7 @@ pub struct Chunk<'lua, 'a> {
}
/// Represents chunk mode (text or binary).
#[derive(Clone, Copy)]
#[derive(Clone, Copy, Debug)]
pub enum ChunkMode {
Text,
Binary,

View File

@ -7,6 +7,7 @@ use crate::table::{TablePairs, TableSequence};
use crate::value::Value;
/// A struct for deserializing Lua values into Rust values.
#[derive(Debug)]
pub struct Deserializer<'lua>(Value<'lua>);
impl<'lua> Deserializer<'lua> {

View File

@ -13,6 +13,7 @@ use crate::util::{check_stack, StackGuard};
use crate::value::{ToLua, Value};
/// A struct for serializing Rust values into Lua values.
#[derive(Debug)]
pub struct Serializer<'lua> {
lua: &'lua Lua,
options: Options,