Closed gftea closed 1 year ago
That implementation looks fine to me.
Here is what I have in the reference solution, but it is effectively equivalent:
use crate::compare::Path;
impl Display for Path {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
for (i, segment) in self.segments.iter().enumerate() {
if i > 0 {
formatter.write_str("::")?;
}
segment.fmt(formatter)?;
}
Ok(())
}
}
Hi
For a
Path
type forError::Fmt
, how to print it exactly same as the code? When I convert it to tokenstream, then print it, it has space between path segments and punct.At present, I have to use quite a long expression to get the string