The undergraduate, who cannot be named for legal reasons, told a jury she was attacked shortly before 7am on November 15, 2014.
The 20-year-old woman told the High Court that she fell unconscious after her attacker started choking her.
She said that when she regained consciousness, she was lying on the ground. The court heard that her attacker was on top of her and the woman said he raped her.
She told the court she was wearing a dress and leggings, and added: “When he started pulling my leggings down – that’s when I realised what he was going to do.
“I think I shouted ‘stop’. I didn’t shout ‘help’. It was a weird moment. I think I shouted ‘please don’t do this here’.
“He grabbed my neck again so I couldn’t speak or breathe and that’s when I started to fight against him.
“It was a struggle for life. I had this moment that I couldn’t breathe. There was this moment that I started shaking myself to get some air.”
The woman was giving evidence on the second day of proceedings against 23-year-old Steven Davidson.
Davidson, from Newtongrange, denies raping the woman and also denies a second charge of being involved in supplying drugs at various locations in Edinburgh in November 2014.
The woman yesterday told prosecution lawyer Jane Farquharson that she had spent the previous evening with friends at parties and at a nightclub. She told Ms Farquharson that she had taken drugs during the previous evening. However, she told the advocate depute that the narcotics had “worn off” at the time she was allegedly attacked.
She told the court that she heard footsteps behind her and thought it was a friend.
In court, she described her alleged attacker as being white, of average build with a “firm” jawline.
She said: “He was a little bit taller than me. He had a very cold stare from his eyes. He was very pale.”
The woman also said her attacker was wearing a black tracksuit at the time of the attack. She also told the court that the alleged attack has had long-term consequences. She told Ms Farquharson: “I still get scared when I hear somebody running behind me.”
Davidson has pleaded not guilty to the charges.
The trial, before Judge Lady Stacey, continues.