Relation between rank and number of distinct eigenvalues $3 \times 3$ matrix B has eigenvalues 0, 1 and 2. Find the rank of B.
I understand that $0$ being an eigenvalue implies that rank of B is less than 3.
The solution is here (right at the top).  It says that rank of B is 2 because the number of distinct non zero eigenvalues is 2.
This thread says that the only information that the rank gives is the about the eigenvalue $0$ and its corresponding eigenvectors.
What am I missing?

Edit
 What I am really looking for is an explicit answer to this: 

"Is the rank of a matrix equal to the number of distinct non zero eigenvalues of that matrix?"  Yes/No/Yes for some special cases

 A: Take for example the matrix $A= \begin{bmatrix} 1 & 0 & 0 \\ 0 & 2 & 0 \\0 & 0 & 0 \end{bmatrix}$,  its rank is obviously $2$, eigenvalues are distinct and are $0,1,2$.
We have theorem which says that if eigenvalues are distinct then their eigenvectors must be linearly independent, but the rank of the matrix is $n-1$ if one of this eigenvalues is zero.
Edit after question edit
To answer more generally we need Jordan forms.  
Let $A$ be $n$-dimensional square matrix with $n-k$ non-zero eigenvalues
(I don't make here a distinction between all different values and repeated- if all are distinct then there are $n-k$ values , if some are with multiplicities then summarize their number with multiplicities to make full sum $n-k$)    and $k$ zero eigenvalues.
Express $A$ through similarity with the Jordan normal form $A=PJP^{-1}$.
The matrix $J$ can be presented as composition $J= \begin{bmatrix} J_n & 0   \\0 & J_z   \end{bmatrix}$ where $J_n$ is a square part of Jordan matrix with $n-k$ non-zero  values (which are eigenvalues) on diagonal and $J_z$ is a square part of Jordan matrix with  $k$ zero  values on its diagonal.
It is clear that because on the diagonal of upper-triangular matrix $J_n$ are non-zero values and the determinant as the product of these values is non-zero so  $J_n$ has full rank i.e. $n-k$.  
The rank of $J_z$ depends on the detailed form of this matrix and it can be from $0$ (when $J_z=0$) to $k-1$  ( see examples in comments). It can't be $k$ because $J_z$ is singular.
Therefore the final rank of $J$ can be from $n-k$ to $n-1$.
Similarity preserves rank so the rank of $A$ can be also from $n-k$ to $n-1$.
A: If the linear transformation has eigen-vectors with distinct eigenvalues, then they are linearly independent(check it, it's easy). Therefore, we know that $\lambda_1u $, $\lambda_2v\in Im(T)$, where $u$ and $v$ are the eigenvectors. Since they are non-zero and linearly independent (the fact that they are multiplied by constants does not change it) we know that $dim(Im(T)) \geq 2$.
A: Because the eigenvalues are distinct, eigenvectors are distinct, and there is a eigen-space spanned by them. The resulting matrix is $$
\begin{bmatrix}
0 &0 &0 \\
0 &1 &0 \\ 
0 &0 &2 \\
\end{bmatrix}
$$ And the rank is 2. A rank is the dimension of space spanned by all image in current space.
