In analogy with the Singleton defect for classical codes, we propose a definition of rank defect for Delsarte rank-metric codes. We characterize codes whose rank defect and dual rank defect are both zero, and prove that the rank distribution of such codes is determined by their parameters. This extends a result by Delsarte on the rank distribution of MRD codes. In the general case of codes of positive defect, we show that the rank distribution is determined by the parameters of the code, together the number of codewords of small rank. Moreover, we prove that if the rank defect of a code and its dual are both one, and the dimension satisfies a divisibility condition, then the number of minimum-rank codewords and dual minimum-rank codewords is the same. Finally, we discuss how our results specialize to Gabidulin codes.