Skip to content

Curious if Debug can removed? #287

Answered by JPHutchins
JPHutchins asked this question in Q&A
Discussion options

You must be logged in to vote

Agh! Debug is resolved easily with #[bitfield[u64, debug = false]]

use bitfield_struct::bitfield;
use binrw::{BinRead, BinReaderExt};

#[bitfield[u64, debug = false]]
#[derive(BinRead)]
struct Header {
    command_id: u8,
    sequence: u8,
    group_id: u16,
    length: u16,
    flags: u8,
    #[bits[3]]
    op: u8,
    #[bits[2]]
    version: u8,
    #[bits[3]]
    _reserved: u8,
}


impl std::fmt::Debug for Header {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "Header {{ op: {}, version: {}, flags: {}, length: {}, group_id: {}, sequence: {}, command_id: {} }}",
            self.op(),
            self.version(),
            self.flags(),

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by JPHutchins
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #286 on August 15, 2024 22:20.