Implement ToRow for T where T: IntoValue
I was trying to use a single value as the argument to prep_exec, and I was surprised when I couldn't pass the value val or (val) to the function. I had to pass (val,), which makes sense in retrospect, but I don't see why ToRow couldn't just be implemented for the type T directly.
I tried, but
src/value.rs:732:1: 736:2 error: conflicting implementations for trait `value::ToRow` [E0119]
src/value.rs:732 impl<'a, T: ToRow + Clone> ToRow for &'a T {
src/value.rs:733 fn to_row(self) -> Vec<Value> {
src/value.rs:734 self.clone().to_row()
src/value.rs:735 }
src/value.rs:736 }
If you remove the implementation for &'a T, will the implementation for T cover that case?
No. It starts to conflict with all non-generic impls of IntoValue trait.
There a three traits involved in making execute to work:
- IntoValue - takes ownership and implemented for all terminal types.
- ToValue - this trait is used in
ToRow for &[&ToValue]becauseToRow for &[&IntoValue]will always dereference DST ref. It works viaToValue for &T where T: IntoValue + Clone. - ToRow - this trait is implemented for tuples,
&[&ToValue],Vec<Value>itself and&T where T: ToRow.
And something always broke when i trying to implement ToRow for IntoValue.
There is a way to implement ToRow for IntoValue but i must sacrifice ToRow for &T where T: ToRow and i am not sure i should do this to be able to write t instead of (t,).
Maybe you have arguments which helps me to make this decision?