Metric space on which every function is uniformly continuous I would like to ask your thoughts on the following problem:

“Characterise the metric spaces in which every function is uniformly continuous”

The first thing I observed is that every subset of such metric spaces (let us call them X for the sake of semplicity) must be open for otherwise there would be some metric spaces Y and some function $f:X \rightarrow Y$ which may not be continuous (hence, also not uniformly continuous). Then, I conjectured that X must be compact, in fact, by the Heine-Cantor theorem this is a sufficient condition; however I can not manage to find a counter-example for when X is not compact in order to conclude that it is also necessary.
Any help or hint is much appreciated!
 A: As you rightly point out, since every function from $X$ to any other metric space $Y$ is continuous, every subset of $X$ is an open set.
(By the way, are you sure that the question doesn't mean "every function from $X$ to $X$ is continuous"?)
In the study of general topology, when every subset of $X$ is an open set, we say that $X$ has the discrete topology.
Let's now apply the condition about uniform continuity. My first instinct is that the infimum of $d(x,y)$ for $x\neq y$ has a role to play. And indeed it does. Let's call the infimum $r$.
If $r>0$, then every function is of course uniformly continuous. The image of each $s$-ball is a single point, for $s<r$.
What if $r=0$?
Then, with the help of the axiom of choice, choose sequences $x_i,x'_i$ such that $d(x_i,x'_i)$ decreases strictly to $0$, and such that all these points are distinct, i.e. no point is used more than once here.
Now, you can construct a function from $X$ to $X$, which sends $x_i$ to $x_1$, and $x'_i$ to $x'_1$. It wouldn't matter where the function sends any other point. The function is not uniformly continuous.
$\\$
In conclusion, for metric spaces $X$,
"every function on $X$ is uniformly continuous" is equivalent to
"there is some $c>0$ such that all pairs of points have distance at least $c$".
$\\$
EDIT: I forgot to explain a subtle technical point.
We know that a subset containing only one point $p$ is open. This means that for each $p$, there is some radius $s_p$ such that the open ball $B(p,s_p)$ contains only $p$.
This point is relevant to the following question. When we were dealing with the case $r=0$, how can we be sure that we can choose $x_i,x'_i$, so that we do not use any point more than once? (We want to ensure this, because we want all the $x_i$ to be mapped to $x_1$, and all the $x'_i$ to be mapped to a point $x'_1$ which is different from $x_1$. If $x'_6=x_4$, for example, then $x'_6$ will map to both $x'_1$ and $x_1$, which we don't want.)
We can do this, as shown by induction. Suppose you have already chosen $x_1,\ldots,x_n$ and $x'_1,\ldots,x'_n$. We want to choose $x_{n+1}$ and $x'_{n+1}$ so that neither equals any of those. Just draw an open ball around each of those such that each open ball contains only that one point.
Take the minimum $m$ of those radii. And declare that $x_{n+1}$ and $x'_{n+1}$ will have distance less than $m$. Such a choice is always possible, because the infimum of $d(x,y)$ for $x\neq y$ is assumed to be $0$.
It follows that $x_{n+1}$ and $x'_{n+1}$ do not repeat the previous points, because the open ball of radius $m$ around $x_{n+1}$ contains $x'_{n+1}$, and vice versa. Yet an open ball of radius $m$ around each of the previous points contains only one point.
