mirror of
https://github.com/italicsjenga/valence.git
synced 2024-12-24 06:51:30 +11:00
impl Display for BlockState
This commit is contained in:
parent
24cf864ed1
commit
54e0d5cb90
18
src/block.rs
18
src/block.rs
|
@ -1,6 +1,6 @@
|
||||||
#![allow(clippy::all, missing_docs)]
|
#![allow(clippy::all, missing_docs)]
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt::{self, Display};
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
@ -11,8 +11,19 @@ use crate::protocol::{Decode, Encode, VarInt};
|
||||||
include!(concat!(env!("OUT_DIR"), "/block.rs"));
|
include!(concat!(env!("OUT_DIR"), "/block.rs"));
|
||||||
|
|
||||||
impl fmt::Debug for BlockState {
|
impl fmt::Debug for BlockState {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
fmt_block_state(*self, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for BlockState {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let kind = self.to_kind();
|
fmt_block_state(*self, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fmt_block_state(bs: BlockState, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
let kind = bs.to_kind();
|
||||||
|
|
||||||
write!(f, "{}", kind.to_str())?;
|
write!(f, "{}", kind.to_str())?;
|
||||||
|
|
||||||
|
@ -29,13 +40,12 @@ impl fmt::Debug for BlockState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.entry(&KeyVal(p.to_str(), self.get(p).unwrap().to_str()));
|
list.entry(&KeyVal(p.to_str(), bs.get(p).unwrap().to_str()));
|
||||||
}
|
}
|
||||||
list.finish()
|
list.finish()
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Encode for BlockState {
|
impl Encode for BlockState {
|
||||||
|
|
Loading…
Reference in a new issue