Skip to content

defmt format - #840

Merged
alejandro-vaz merged 3 commits into
servo:v2from
Divyansh089:defmt-format
Nov 1, 2026
Merged

alejandro-vaz merged 3 commits into
servo:v2from
Divyansh089:defmt-format

Conversation

@Divyansh089

Copy link
Copy Markdown
Contributor

implements defmt::Format for every public type that implements Debug:
Drain, IntoIter, ExtractIf, Splice and SmallVecError (SmallVec already had it).

  • all impls are gated behind the defmt feature.
  • each one prints the same as its Debug impl.
  • SmallVecError is implemented by hand, since core::alloc::Layout doesn't implement Format.

added tests/defmt.rs, which checks at compile time that each type implements Format.

Closes #795

@alejandro-vaz alejandro-vaz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implement it for RawSmallVec and LocatedLength as well, along with Debug

Comment thread tests/defmt.rs Resolved
Comment thread Cargo.toml Resolved
Comment thread src/error.rs Resolved
@Divyansh089

Copy link
Copy Markdown
Contributor Author

done.

  • added Debug and defmt::Format to both
  • locatedLength prints its length and on_heap. RawSmallVec prints RawSmallVec { .. }: the union doesn't know which member is active (locatedLength tracks that), so reading either one here would be UB

@alejandro-vaz alejandro-vaz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. thanks @Divyansh089

@alejandro-vaz
alejandro-vaz added this pull request to the merge queue Nov 1, 2026
Merged via the queue into servo:v2 with commit 168e43a Nov 1, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

extend defmt support

2 participants