Could we ever fix naming of `io::Write::write`?

I don't know how such information could be collected and presented for you to find it convincing.

I've lamented about this footgun before:

I've found this bug in a lot of places. In noobs' code. In code by experienced devs who work professionally on network services. In cargo. In cranelift. In rustdoc. I the png and gif crates. In xml-rs. In firecracker. In rav1e. In openssl and boring. In serde. In sccache. In flate2. In hyper. Even an early version of docs for std::io had this bug in the examples.

It's everywhere. In old code. In new code.

I just grepped for uses of .write in Rust, and already found more suspicious examples than intentional uses of write:

And the intentional one looks like it could have been write_all too.


Run that on any large project, and you'll find how often this had to be fixed:

git log -pS .write_all\( | grep -EA1 '^-.*\.write\(' | egrep -EB1 '^\+'

I suspect that if Rust won't complain about implementing fn write(…) for the io::Write trait or uses of .write() inside this method, then there won't be any churn. Intentional uses of partial .write() seem to be incredibly rare.

30 Likes