Repository navigation
fix: format deeply nested trees - #132
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #132 +/- ##
==========================================
+ Coverage 95.32% 95.33% +0.01%
==========================================
Files 27 27
Lines 4040 4054 +14
==========================================
+ Hits 3851 3865 +14
Misses 189 189 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| FdtEventIter::new(self) | ||
| } | ||
|
|
||
| pub(crate) fn write_indent<W: fmt::Write>(f: &mut W, indent: usize) -> fmt::Result { |
There was a problem hiding this comment.
Because this is pub(crate) and used in fdt/property.rs as well, can we move this to src/utils.rs?
| const SPACES: &str = " "; | ||
|
|
||
| for _ in 0..indent / SPACES.len() { | ||
| f.write_str(SPACES)?; | ||
| } | ||
| f.write_str(&SPACES[..indent % SPACES.len()]) |
There was a problem hiding this comment.
I think it's fine to just use write_char here in a loop, instead of using the SPACES constant here. I get it that write_str can be faster, but I'd like to avoid having unnecessary data in the binary, unless we benchmark that it's worth it.
|
@m4tx Thanks for the review. I moved the shared indentation helper into the existing |
m4tx
left a comment
There was a problem hiding this comment.
Looks good to me - the last issue to address is moving the unit test into a test module.
|
@m4tx Moved \large_indentation_does_not_panic\ into a #[cfg(test)] mod tests\ block at the bottom of \src/util.rs\ (placed after |
m4tx
left a comment
There was a problem hiding this comment.
Amazing, thanks! Please rebase the changes on top of current main branch so that we can merge this.
77ceb3d to
6ce2d03
Compare
|
Thanks for the review. The indentation test is in a On Windows, |
Summary
u16::MAXFixes #103
Validation
cargo fmt --all -- --checkcargo test --locked --all-features(143 tests passed)cargo clippy --locked --all-features --all-targets(passes with existing warnings outside this change)git diff --check