arrayvec icon indicating copy to clipboard operation
arrayvec copied to clipboard

implement std::fmt::Write

Open piegamesde opened this issue 4 years ago • 4 comments

I'd like to print! to an ArrayVec or ArrayString on no_std, where std::io::Write does not exist.

piegamesde avatar Oct 05 '21 15:10 piegamesde

fmt::Write is already implemented for ArrayString, so that part's done. How would it work with Arrayvec? There's no precendent (Vec doesn't implement fmt::Write), but if it's explained, maybe it's a good idea?

bluss avatar Oct 05 '21 18:10 bluss

Oh, I didn't think to check ArrayString, sorry about that! I just saw that heapless had an implementation and that arrayvec didn't. At the core, they simply do self.extend_from_slice(s.as_bytes()) which looks sensible to me.

piegamesde avatar Oct 05 '21 18:10 piegamesde

Yes, that looks good, we can do that for arrayvec

bluss avatar Oct 16 '21 08:10 bluss