We study the row-space partition and the pivot partition on the matrix space $mathbb{F}_q^{n times m}$. We show that both these partitions are reflexive and that the row-space partition is self-dual. Moreover, using various combinatorial methods, we explicitly compute the Krawtchouk coefficients associated with these partitions. This establishes MacWilliams-type identities for the row-space and pivot enumerators of linear rank-metric codes. We then generalize the Singleton-like bound for rank-metric codes, and introduce two new concepts of code extremality. Both of them generalize the notion of MRD codes and are preserved by trace-duality. Moreover, codes that are extremal according to either notion satisfy strong rigidity properties analogous to those of MRD codes. As an application of our results to combinatorics, we give closed formulas for the $q$-rook polynomials associated with Ferrers diagram boards. Moreover, we exploit connections between matrices over finite fields and rook placements to prove that the number of matrices of rank $r$ over $mathbb{F}_q$ supported on a Ferrers diagram is a polynomial in $q$, whose degree is strictly increasing in $r$. Finally, we investigate the natural analogues of the MacWilliams Extension Theorem for the rank, the row-space, and the pivot partitions.