Make Debug instances behave like those for slices#211
Merged
Lokathor merged 1 commit intoLokathor:mainfrom Dec 19, 2025
Merged
Conversation
The indentantion in case of structs inside the arrays was wrong with pretty debug instance. Instead of rolling one by hand, just use the underlying slice implementation. It appears that this was even the intention orginally, based on the `TinyVec_pretty_debug` test. The main issue is that the test used a simple value instead of a struct so it missed the problem. FWIW I have kept the existing test but I think it could just be deleted now. I haven't touched the `Display` version because while slices have a `Debug` impl, there isn't one for `Display`. So I think probably `Display` has the same problem. These tests can technically be written in a non-alloc/non-std way by defining an array-backed buffer and giving it `core::fmt::Write` but I was too lazy to do so: it doesn't seem useful. Fixes Lokathor#192.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The indentantion in case of structs inside the
arrays was wrong with pretty debug instance.
Instead of rolling one by hand, just use the
underlying slice implementation. It appears that
this was even the intention orginally, based on
the
TinyVec_pretty_debugtest. The main issue is that the test used a simple value instead of astruct so it missed the problem. FWIW I have kept
the existing test but I think it could just be
deleted now.
I haven't touched the
Displayversion becausewhile slices have a
Debugimpl, there isn't onefor
Display. So I think probablyDisplayhasthe same problem.
These tests can technically be written in a
non-alloc/non-std way by defining an array-backed
buffer and giving it
core::fmt::Writebut I wastoo lazy to do so: it doesn't seem useful.
Fixes #192.