rust-lang/rust — pull request #16544 by pczarn (2014-08-17 00:36:20+00:00)
Title: (WIP) Add the `size_hint` method to Show as a default method

I'm trying to balance code bloat and precision of the upper bound.

* Can `size_hint` default to 0 instead of None?
* How costly are occasional errors?
* How to implement `size_hint` for floats? I've yet to think about it.
* Is `size_hint` also that useful for the general case of `format!`, as implemented in this PR?

UFCS would make this change prettier.

## Examples
```rust
format!("{}", 0u).byte_capacity() // => 1
format!("{}", 7u).byte_capacity() // => 1
format!("{}", 8u).byte_capacity() // => 2
format!("{}", 18446744073709551615u64).byte_capacity() // => 32
format!("abc{}efg", 123u).byte_capacity() // => 9
```

Fixes #16415