Question: how to stop thinking about a guy you can't have?
Answer: Keep yourself occupied at all times. Look into taking up a new hobby in the aftermath of rejection. Strive to keep busy throughout the day. If you don't keep busy, you're likely to start ruminating and having negative thoughts about yourself and the guy. Take up hobbies you enjoy.