BlockstreamResearch / rust-simplicity

Creative Commons Zero v1.0 Universal
58 stars 12 forks source link

Cannot derive conversion traits for Value #238

Open uncomputable opened 1 month ago

uncomputable commented 1 month ago

Because the constructors of Value return Arc<Value>, it is impossible to derive From implementations in a straightforward way.

impl From<u8> for Arc<Value> {
    | ^^^^^--------^^^^^----------
    | |    |            |
    | |    |            `Arc` is not defined in the current crate
    | |    `u8` is not defined in the current crate
    | impl doesn't use only types from inside the current crate
apoelstra commented 1 month ago

Should be fixed when we replace the recursive Value implemetation with a bitslice and a type. I might give this a shot this week.

apoelstra commented 1 month ago

I gave it a quick shot, mainly to play with Deref and CoerceUnsized etc to try to make an owned and reference type, and have them interact nicely, but wasn't able to get anywhere.

So to do this, we have to do it "the normal way" without exotic Rust features, which is less fun, so I don't plan to do it in the short term unless you really want these From impls to be possible.

uncomputable commented 1 month ago

We can hold off on this issue for now, but I would keep it open for future reference.