So the problem is Exercise $13$, Chap. $4$ of Principles of Mathematical Analysis by Rudin:
Problem
Let $E$ be a dense subset of metric space $X$, and let $f$ be a uniformly continuous real function defined on $E$. Prove that $f$ has a continuous extension from $E$ to $X$.
Following the hint given by the author, I am able to prove this result and understand that the result still holds when the range space of $f$ is replaced by any complete metric space. My question is, does the result also hold when the range space is any metric space? If yes, how to prove, if no, are there any illuminating counterexamples?
Suppose $f:\Bbb Q\to \Bbb Q,\, f(x)=x$. Were there some continuous extension $g:\Bbb R\to \Bbb Q$, would it be possible to define $g(\sqrt 2)$?
PS: I just did exactly this same problem in Baby Rudin yesterday :)