write() methods. The problem is that it's not clear from these methods' names that they have specific behavior which doesn't guarantee reading/writing the full slice. Using these methods as if they were
write_all is a huge footgun. It's a nasty kind of bug, because depending on the underlying I/O implementation, wrong code may mostly work most of the time. I've made that mistake, I've seen others make that mistake.
These methods names look innocent, so the mistake doesn't stand out in code reviews. IMHO names of these methods should reflect their behavior better. I guess Rust's naming is supposed to reflect POSIX functions of the same name. However, "read" and "write" are very generic names, and not something that everyone will immediately understand as referring to very specific best-effort behavior of a couple of low-level system calls.
The functionality of these methods is fine and useful. It's just naming that's a problem. Partial reads/writes are a nice optimization. However, using this optimization correctly requires special care and proper integration into a larger I/O buffering algorithm, so I consider it a specialized use-case, and not something to be given to the shortest/simplest method names.
I suggest migrating away from "bare"
write() names. This might be done by adding an alias like
read_partial(), and Clippy lints and eventually deprecation warnings that suggest using the more specific name, so that the programmer has to consciously decide whether they've meant