New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manually implement Debug on Witness #1913
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK a44857a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with changing the impl but I think it'd be much better to print it as individual elements using debug_list
Can do, thanks! |
Ok, I responded too quickly. Now I've looked at it, unless I'm missing something, using
Is a bad debugging experience and my proposition was that hex is better than an array of decimal values. |
@tcharding did you map the values to display as hex? I think list of hex values would be the best, especially using alternate formatting which gets pretty-printed. |
I also think we should split up the witness fields using
We should also do a |
Nice, I can do all that. Thanks |
With some outrageously ugly code I have it looking like this, please ack/nack the layout and I'll clean up the code. I had to manually implement the whole thing because the fmt helpers take mut self so cannot be used togther ( Top one is debug, bottom one is pretty debug.
|
Looks good to me! Actually, I think I'd prefer if the pretty one still put all the witness bytes for each witness in one line. |
I thought that myself, so if you've thought it too lets do it. |
a44857a
to
a2eb9a1
Compare
Using this format:
Note no space between the square brackets in witnesses on first line, ok with that ? |
e95b116
to
7e00b59
Compare
The code is pretty ugly still. |
To verify output you can use: #[test]
fn debug_witness() {
let witness = Witness {
witness_elements: 3,
content: append_u32_vec(vec![1u8, 0, 2, 2, 3, 2, 4, 5], &[0, 2, 5]),
indices_start: 8,
};
println!("Print in a line {:?}", witness);
println!("Print in a line {:#?}", witness);
} |
7e00b59
to
2778d38
Compare
I'm happy with this. Would also be happy with any variations on the spacing. |
The current derived debug implementation on `Witness` prints the content field as an array of integers. We can do better than this by manually implementing `Debug`. With this applied `Witness` is printed as follows: (first line is `{:?}` and the next is `{:#?}`): Using `{:?}`: ``` Witness: { indices: 3, indices_start: 8, witnesses: [[0x00], [0x02, 0x03], [0x04, 0x05]] } ``` Using `{:#?}`: ``` Witness: { indices: 3, indices_start: 8, witnesses: [ [0x00], [0x02, 0x03], [0x04, 0x05], ], } ```
2778d38
to
d45dbef
Compare
Rebased on master (to pick up #1927). No other changes. |
Kix's seems out-of-action at the moment, @sanket1729 do you have time to take a look at this one please? |
On my list for tomorrow |
Legend! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested ACK d45dbef. This would be helpful for debugging downstream.
In the interest of getting this in, I'll ACK this. But the allocations are really not necessary and we should file an issue to get rid of them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK d45dbef
The current derived debug implementation on
Witness
prints the content field as an array of integers. We can do better than this by manually implementingDebug
.With this applied
Witness
is printed as follows: (first line is{:?}
and the next is{:#?}
):Using
{:?}
:Using
{:#?}
: