This might not be useful more generally, but that if
-let
-else
could be shortened to print!("{}", v.unwrap_or(&", "))
.
Edited to add: The for
loop could be
for v in elements.iter().intersperse(&", ") {
print!("{v}")
}
That seems too simple, so I guess it likely isn't useful.