rust-simplicity icon indicating copy to clipboard operation
rust-simplicity copied to clipboard

Cannot derive conversion traits for Value

Open uncomputable opened this issue 1 year ago • 3 comments

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

uncomputable avatar Jul 24 '24 10:07 uncomputable

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 avatar Jul 24 '24 21:07 apoelstra

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.

apoelstra avatar Jul 25 '24 15:07 apoelstra

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

uncomputable avatar Jul 25 '24 19:07 uncomputable