It is not Just About Self-restraining
According to shari’a definition, fasting is “An act of worship dedicated to Allah the Exalted by restraining from anything that could invalidate it since the breaking of dawn until the sun set.” As for invalidators of fasting, in Islam, are: Eating, drinking, deliberate vomiting, and having sexual intercourse.
If there’s any kind of self-restraining beside it, then it is not considered as fasting in Islam.
For example: If there’s a person who aim to get closer to Allah the Exalted by restraining himself from consuming meat; or by consuming only white rice; or by restraining himself from talking to anyone; or from sleeping; or from sitting; or from sheltering; and so on; those are not valued as fasting in Islam.
In a hadith, it is mentioned that one day, when the Messenger of Allah was preaching, one of his companions chose to stand under the very hot sun. The Messenger asked, what is he doing. The other companions answered that he is Abu Israil, and he had vowed not to sit, take shelter, talk, and he is fasting. Upon hearing that, the Messenger said, “Tell him to sit, shelter, talk, and continue his fast.” (Narrated by Bukhari no. 6704)