Cast the result to the type of the enum