Currently, "literal".to_string() uses Show to transform the value, so it had been consuming larger memory than "literal".into_string(). The difference is lessened, however, by the recent improvements of the formatter. Previously, a minimum of 128 bytes were needed. Now only 2^n bytes.
But I still think using a formatter like Show to convert a &'static str to String is a bit indirect, leading me to having a preference on into_string().
However, I found an interesting idea from this reddit post. I don’t know how this should be called, but the suggested method gives a way to negate some patterns when matching a type in impl, like this:
impl<T: Show + Str> ToString for T { * Convert &'static str directly */ }
impl<T: Show + !Str> ToString for T { /* Use format!(), as usual */ }
I heard C++ got a headache when dealing with multiple inheritance, but using the proposed way, it is guaranteed that only one implementation is matched to a type, so there is no need for a conflict resolution mechanism.
Would that be possible? Are there any caveats in this idea?