Auto merge of #68558 - HeroicKatora:buf-writer-capacity, r=alexcrichton
Auto merge of #68558 - HeroicKatora:buf-writer-capacity, r=alexcrichton

Add a method to query the capacity of a BufWriter and BufReader

Besides the obvious of retrieving the parameter used to construct the writer, this method allows consumers to control the number of `flush` calls during write operations. For `BufReader` it gives an upper bound on the returned buffer in `fill_buf` which might influence the allocation behaviour of a consumer.

graydon/rust,aidancully/rust,aidancully/rust,graydon/rust,graydon/rust,aidancully/rust,aidancully/rust,aidancully/rust,graydon/rust,graydon/rust,aidancully/rust,graydon/rust