http-rs / http-types

Common types for HTTP operations
https://docs.rs/http-types
Apache License 2.0
200 stars 83 forks source link

error: allow backtrace Option to be Display on stable #258

Closed Fishrock123 closed 3 years ago

Fishrock123 commented 3 years ago

This prevents the need for users to do backtrace feature-checking for code that wishes to use Display for a backtrace and also compile on stable.

jbr commented 3 years ago

Why wouldn't the user just test if the option is None?

jbr commented 3 years ago

Ohhh… I see what's going on. What if we just used some already available type like Option<String> (which also implements Display)

Fishrock123 commented 3 years ago

I don't understand? Option<Option<?>>? Option only implements Display if T also does. The idea here is to have the same traits as Backtrace so the type system doesn't complain on stable.

jbr commented 3 years ago

@Fishrock123 sorry, forgot that comments don't auto escape < — typed Option<String>. the String part is what would change. Pretty much any built-in-type that's Display+Debug, because writing code that will never be executed seems a little weird. At the very least, we could unreachable!() it to make clear it shouldn't ever get called

Fishrock123 commented 3 years ago

I would rather it be a type that implements exactly the same traits as Backtrace, personally.

Fishrock123 commented 3 years ago

Ultimately, the correct answer here is that it would be Option<!>, using the experimental never type to denote that it will only ever be None. (And also because never is able to auto-implement all basic traits. Or something.)

jbr commented 3 years ago

Yep, agreed that ! would be ideal if stable