The author is going towards the right solution but their solution has things flipped, and the result feels like a hack. What I would suggest is instead of implementing a trait with a magic type parameter, you should instead solve this by providing an object that dispatches the trait method rather than dispatching it from the target type.
That is, instead of "trait ToJson { fn to_json(&self) -> Json }" you should have "trait JsonSerializer<T> { fn to_json(&self, what: &T) -> Json }". Now we can implement "impl JsonSerializer<Date> for ISO8601" and "impl JsonSerializer<Date> for TimestampSeconds".
If this seems a little wordy, realize that actually we've just reimplemented Rust's closures as our own custom trait. So we could just use closures: "JsonSerializer<T>" is the same thing as the trait "Fn(&T) -> Json". This is exactly what serde features, as you can pass in a serializer function rather than using the type itself to look up the behavior[1].
One other place this commonly comes up for me is in comparisons. Some types, like strings, don't have a single universal way to compare them. This means that Ord is insufficient. The solution is to have a "comparator" trait that provides the ordering. Again, this could also just be a closure with two arguments.
The orphan rule prevents some bad things, and prevents some other good things. It's hardly an unambiguous win and seeing the compiler devs so adamant to defend their position at the expense of users is a reflection on larger culture.
You can't prevent people from doing the wrong thing (assuming you're even able to accurately determine that), all you can do is make doing the right thing easy.
While I think rust is one of the best languages today, this is a corner where it reminds me of C++: Here is a rule with lots of tiny special cases, it has painful consequences in the real world, and if everyone adds some 'best practice' magic to their code, we have 90% of a solution.
That is, instead of "trait ToJson { fn to_json(&self) -> Json }" you should have "trait JsonSerializer<T> { fn to_json(&self, what: &T) -> Json }". Now we can implement "impl JsonSerializer<Date> for ISO8601" and "impl JsonSerializer<Date> for TimestampSeconds".
If this seems a little wordy, realize that actually we've just reimplemented Rust's closures as our own custom trait. So we could just use closures: "JsonSerializer<T>" is the same thing as the trait "Fn(&T) -> Json". This is exactly what serde features, as you can pass in a serializer function rather than using the type itself to look up the behavior[1].
One other place this commonly comes up for me is in comparisons. Some types, like strings, don't have a single universal way to compare them. This means that Ord is insufficient. The solution is to have a "comparator" trait that provides the ordering. Again, this could also just be a closure with two arguments.
[1]: https://serde.rs/field-attrs.html#serialize_with
You can't prevent people from doing the wrong thing (assuming you're even able to accurately determine that), all you can do is make doing the right thing easy.
Might as well live adventurously