mirror of
https://github.com/italicsjenga/valence.git
synced 2024-12-23 22:41:30 +11:00
Add Debug impl to BlockState
This commit is contained in:
parent
1a27cb92ce
commit
f5f8264a70
30
src/block.rs
30
src/block.rs
|
@ -1,7 +1,37 @@
|
||||||
#![allow(clippy::all)]
|
#![allow(clippy::all)]
|
||||||
|
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/block.rs"));
|
include!(concat!(env!("OUT_DIR"), "/block.rs"));
|
||||||
|
|
||||||
|
impl fmt::Debug for BlockState {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let typ = self.to_type();
|
||||||
|
|
||||||
|
write!(f, "{}", typ.to_str())?;
|
||||||
|
|
||||||
|
let props = typ.props();
|
||||||
|
|
||||||
|
if !props.is_empty() {
|
||||||
|
let mut list = f.debug_list();
|
||||||
|
for &p in typ.props() {
|
||||||
|
struct KeyVal<'a>(&'a str, &'a str);
|
||||||
|
|
||||||
|
impl<'a> fmt::Debug for KeyVal<'a> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
write!(f, "{}={}", self.0, self.1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list.entry(&KeyVal(p.to_str(), self.get(p).unwrap().to_str()));
|
||||||
|
}
|
||||||
|
list.finish()
|
||||||
|
} else {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
Loading…
Reference in a new issue