In reply to Tudor Timi:
Actually, upon reading a bit further, notice that the syntax for $cast(…) is:
function int $cast( singular dest_var, singular source_exp );
Section 6.4 Singular and aggregate types states that unpacked structs (that the OP was using) aren’t singular types, so the compile error, though a bit lacking on the details, is correct.