Yesterday I tried to convert the representation of a number into another representation/type in Rust:
let coeff = BigUint::from_str(x).unwrap();
let coeff: <<G1Affine as AffineCurve>::ScalarField as PrimeField>::BigInt =
coeff.try_into().unwrap();
let x: <G1Affine as AffineCurve>::ScalarField = coeff.into();
I wrote that, then I wanted to move that code in a function so I wrote:
fn string_int_to_field_el(s: &str)
copilot suggested the following one-liner that did exactly the same thing:
fn string_int_to_field_el(s: &str) -> <G1Affine as AffineCurve>::ScalarField {
let x: <G1Affine as AffineCurve>::ScalarField = s.parse().unwrap();
x
}
I still don't understand how some heuristics could produce this code. It's mind blowing.