Skip to content

Implement defmt for v2 - #391

Open
darkwater wants to merge 1 commit into
servo:v2from
darkwater:v2-defmt
Open

Implement defmt for v2#391
darkwater wants to merge 1 commit into
servo:v2from
darkwater:v2-defmt

Conversation

@darkwater

Copy link
Copy Markdown

Implements #389 for v2 (also see #390)

Comment thread src/lib.rs
Comment on lines +566 to +577
#[cfg(all(feature = "extract_if", feature = "defmt"))]
#[cfg_attr(docsrs, doc(cfg(feature = "defmt")))]
impl<T, const N: usize, F> defmt::Format for ExtractIf<'_, T, N, F>
where
F: FnMut(&mut T) -> bool,
T: defmt::Format,
{
fn format(&self, fmt: defmt::Formatter) {
defmt::write!(fmt, "ExtractIf({:?})", self.vec.as_slice());
}
}

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.

separate this into its own file defmt.rs and conditionally link it

Comment thread src/lib.rs
Comment on lines +654 to +664
#[cfg(feature = "defmt")]
impl<'a, I, const N: usize> defmt::Format for Splice<'a, I, N>
where
I: Iterator + 'a,
<I as Iterator>::Item: defmt::Format,
{
fn format(&self, fmt: defmt::Formatter) {
defmt::write!(fmt, "Splice({:?})", self.drain);
}
}

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.

same as above

Comment thread src/lib.rs
Comment on lines +2878 to +2904
#[cfg(feature = "defmt")]
#[cfg_attr(docsrs, doc(cfg(feature = "defmt")))]
impl<T: defmt::Format, const N: usize> defmt::Format for SmallVec<T, N> {
fn format(&self, fmt: defmt::Formatter) {
defmt::write!(fmt, "{=[?]}", self.as_slice());
}
}

#[cfg(feature = "defmt")]
#[cfg_attr(docsrs, doc(cfg(feature = "defmt")))]
impl<T: defmt::Format, const N: usize> defmt::Format for IntoIter<T, N> {
fn format(&self, fmt: defmt::Formatter) {
defmt::write!(fmt, "IntoIter({=[?]})", self.as_slice());
}
}

#[cfg(feature = "defmt")]
#[cfg_attr(docsrs, doc(cfg(feature = "defmt")))]
impl<T: defmt::Format, const N: usize> defmt::Format for Drain<'_, T, N>
where
T: defmt::Format,
{
fn format(&self, fmt: defmt::Formatter) {
defmt::write!(fmt, "Drain({=[?]})", self.iter.as_slice());
}
}

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.

same as above

@alejandro-vaz alejandro-vaz added this to the v2-alpha milestone Aug 27, 2026
@alejandro-vaz alejandro-vaz added p-medium Medium priority r-feature related to a new feature and removed p-medium Medium priority r-feature related to a new feature labels Aug 27, 2026
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.

2 participants