Ibn Rajab and others gave an account of a worshipper who ran out of resources while he was in Makkah. He became extremely hungry and was about to die from lack of nourishment. One day, as he was wandering in the precincts of Makkah, he found an expensive necklace. He put it into his sleeves and headed for the Mosque. On his way he came across a man who was announcing that he had lost a necklace. The poor man later said, "l asked him to describe it to me, and he did so perfectly, leaving no room for doubt. I gave him the necklace without taking reward from him. I said: O’ Allah, I have given it up for you, so compensate me with what is better." He then went to the ocean and began a journey in a small boat. Only a brief period of time passed before a storm came with heavy winds crashing into the boat. The boat smashed into pieces and the man was forced to cling to a piece of wood. The violent winds propelled him to the left and to the right. Finally, he was washed ashore onto an island. He found there a Mosque filled with people who were praying, so he joined them. He found papers with parts of the Qur’an written on them and he began to recite from them. The people of the island asked him, "Do you read the Qur’an'?" He answered in the affirmative. They said, "Teach our children the Qur’an. " So he began to teach them, and he took a salary for his services. One day, they saw him writing and they asked, "Will you teach our children to write?"
Again he answered in the affirmative and began teaching them for a salary.
A short time later they said to him, “There is an orphaned girl with us whose father was a good man. Will you many her?" He agreed to the marriage and later related, "I married her and when I saw her on the wedding night, I found that she was wearing that exact same necklace. I asked her to tell me the story of the necklace. She said that her father lost it in Makkah and a man found it and returned it to him. She said that her father would always supplicate while prostrating for her daughter to become blessed with a husband similar to that honest man. I then informed her that I was that man."
He abandoned something for the sake of Allah, so Allah compensated him with something that was better.
“Verily, Allah is good and pure, and He does not accept other than what is good and pure."