Pre-ACP: Un-specialize impl ToString

You should probably explain why the added method isn't simply fn(&self) -> String. Actually, at the very moment that I'm writing this, I realise this might be the simple problem of core vs alloc, right?

Anyways, also I feel like you're pessimizing the implementation for str which now does go through a dynamic function call to dyn Write, doesn't it?


Edit: Thinking some more of core-compatible alternatives to fn(&self) -> String... Maybe something like fn<S: TraitForRelevantApiOfString>(&self) -> S[1] could work fine? And then for object safety... well, a Self: Sized bound could work; except that that precludes the implementation for str which isn't Sized. If we ever got something like what was just mentioned here yesterday though, that might be enough :thinking:

Edit2: Nevermind the previous paragraph. I think it doesn't work this way, because with Self: Sized or Self: NoDyn you still no longer could call the thing in the generic implementation of ToString for T: Display + !Sized.


  1. some of the relevant API of String would probably include a from_str method, a with_capacity constructor, and a push_str method. Maybe thats all that's needed already? ↩︎