Hello. Thank you for coming to JustAnswer with your question, and welcome.
What part of your toe was painful?
Did it appear swollen, or reddened at all?
Whatever you did to it, the ice and elevation must have kept it from swelling.
You may have (as you suggest) hit your toe against something while sleeping. More likely, you mildly sprained the ligaments in the toe that day. Anything else (arthritis, gout, more severe injury) would have caused some redness and swelling.
An injury of the big toe (or joint) is called "turf toe"......here is a link to a small video that explains: Turf Toe
Applying ice and elevating the foot is actually the correct treatment for this type of injury.