feat: nicer debug repr for instr id and socketidx

This commit is contained in:
MultisampledNight 2024-01-20 17:59:21 +01:00
parent 8b6f9810df
commit 98c9399ee4
No known key found for this signature in database
GPG key ID: 6D525AA147CBDAE2

View file

@ -15,15 +15,23 @@
//! The distinction between [`Input`] and [`Output`] is implemented //! The distinction between [`Input`] and [`Output`] is implemented
//! as them being different types. //! as them being different types.
use std::fmt;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// One specific instruction. /// One specific instruction.
/// ///
/// It does **not** contain what kind of instruction this is. /// It does **not** contain what kind of instruction this is.
/// Refer to [`crate::instruction::Kind`] for this instead. /// Refer to [`crate::instruction::Kind`] for this instead.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct Instruction(pub(super) u64); pub struct Instruction(pub(super) u64);
impl fmt::Debug for Instruction {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "InstrId {}", self.0)
}
}
/// On an **instruction**, accepts incoming data. /// On an **instruction**, accepts incoming data.
/// ///
/// An **instruction** cannot run if any of these are not connected. /// An **instruction** cannot run if any of these are not connected.
@ -66,5 +74,11 @@ pub struct Socket {
/// ///
/// This really only serves for denoting where a socket is, /// This really only serves for denoting where a socket is,
/// when it's already clear which instruction is referred to. /// when it's already clear which instruction is referred to.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct SocketIdx(pub u16); pub struct SocketIdx(pub u16);
impl fmt::Debug for SocketIdx {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}