Skip to content

consider changing Jiff's formatting Write trait to return a usize indicating the number of bytes written #431

@BurntSushi

Description

@BurntSushi

If we don't know how many bytes are written, then I think it makes it harder for callers to provide their own &mut [u8] buffers.

On the other hand, we could keep the Write trait the same and either provide a Cursor<T> abstraction (which essentially keeps track of the number of bytes written). Or insist that callers should provide this themselves (and implement the Write trait).

I somewhat lean towards not making a change here. In particular, existing jiff::fmt::Write trait implementations like String and Vec<u8> are already tracking the number of bytes written with their len fields. So having Jiff do it on top of that is just extra work. Plus, insisting that callers implement jiff::fmt::Write themselves should be an enormous burden. And generally speaking, this should only be necessary in core-only environments without a Vec<u8>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changeIssues that require a breaking change for resolution.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions