Why does casting a struct cause an error?

Copilot suggests to do it like that: