lindy-labs / opus_contracts

Opus Source Code
https://opus.money
Other
0 stars 0 forks source link

def: Display using Debug #525

Closed milancermak closed 9 months ago

milancermak commented 9 months ago

A generic impl of Display using Debug.

I think this is safe because it only applies to our types. I've tried making the declaration stricter by using a negative impl -Display<T> but that didn't compile 🤷

milancermak commented 9 months ago

A negative impl, AFAIU, works as a restriction meaning "type does not implement this trait". An opposite of a positive impl ("type implements this trait").

So my idea was to do impl DislayUsingDebug<T, impl TDebug: Debug<T>, -Display<T>> of Display<T> to say "any type that implements Debug but not Display" because we could have e.g. a Display impl for Health in which case we'd want to use the more specific and prevent clashes for the implementation.