Cut the snagged edge off as close to the carpet base as you can. Use very sharp scissors or a utility knife if the snag is at the edge of the carpet. If the snag is in the middle of the carpet, skip this step.
Run a piece of masking tape along each side of the edge of the carpet to protect the rest of the carpet.
Place a bead of carpet glue into the hole(s) where the yarn has come loose.
Weave the pulled edge of yarn back through the carpet backing using a knitting needle or awl. Push the yarn back into place as loops in the backing.
Pull the fiber until the snagged loop is a little longer than the loops around it. Continuing doing this with the rest of the row and with wear the loops will eventually even out.
Leave the rug edge alone until the carpet glue dries according to manufacturer instructions. Remove the masking tape once the glue is dry.