Affect RectTransform rotation in script

I have been trying to do this for the better part of 20 minutes now, and it doesn’t seem to work very well.

I am trying to apply a Vector3 to a RectTransform UI object so it will snap to that rotation when the function is called.

public Image toggleHandle;
    Vector3 toggleRotation = new Vector3(0f, 0f, 180f);

public void Update()
    {
        if (toggle.isOn)
        {
            toggleHandle.rectTransform.transform.rotation = toggleRotation;
        }
    }

transform.rotation is not a Vector3 but a Quaternion.
If you like to set the rotation via a Vecor3 you should use transform.eulerAngles.