Description
Right now, libcore contains default implementations of the ToStr trait for pointers to ToStr-able implementations:
impl<A: ToStr> @A: ToStr { basically: "@" + (*self).to_str () }
To the best of my understanding, it isn't possible to override these implementations (see issue #4851). If this is the case, I argue that these default implementations are far too restrictive and should be removed.
Consider a case where you have some stack object with a meaningful ToStr. If you have a pointer to that object, I'd say that it's much more plausible that you'll want that pointer to yield the same string, not "@" + that string. If you don't want that, you at least want control over the stringification.
It only makes sense to require the current semantics if ToStr is defined as behaving like Python's repr
functionality. But it isn't. (For instance, quite reasonably (s: str).to_str() = s
, not "\"" + escape(s) + "\""
.)
If I comment out the default implementations for pointers and the tests specific to those pointers, I can rebuild all of Rust and all of the remaining tests pass.
If these default implementations are removed, then (~[1, 2, 3]).to_str()
starts evaluating to "[1, 2, 3]" rather than "~[1, 2, 3]". I claim that this is desirable.