If$|f(x)-f(y)|\le (x-y)^2$, prove that $f$ is constant (Baby Rudin Chapter 5 Exercise 1)

Let $f$ be defined for all real $x$, and suppose that
\begin{equation}\tag{1}
    |f(x)-f(y)|\le (x-y)^2
\end{equation}
Prove that $f$ is constant.

My attempt:

Let $f$ be defined for all real-valued inputs. Let $x \in \mathbb{R}$ and $y \in \mathbb{R} \smallsetminus \{ x \}$, and suppose that (1) holds.
Then, we have:
\begin{align*}
        \left| \dfrac{f(x)-f(y)}{x-y}\right| \le (x-y)
    \end{align*}
As $x\to y,  \lim\limits_{x \to y}\left| \dfrac{f(x)-f(y)}{x-y}\right| \le 0$. Since it cannot be that $\left|f'(y)\right| < 0$, we have that $\left|f'(y)\right| = 0 \implies f'(y) = 0$.

Can someone please read over my proof and let me know if it is correct?
 A: Your deduction that $$\frac{|f(x)-f(y)|}{|x-y|}\le x-y$$ is incorrect because it would lead to $$|f(x)-f(y)|\le |x-y|\cdot(x-y)\ne (x-y)^2$$ To make it work, you may want to deduce that $$\frac{|f(x)-f(y)|}{|x-y|}\le |x-y|$$
Your solution is otherwise correct.
A: Technically there is a slight mistake.
You took $x\in \Bbb{R}$ and $y\in \Bbb{R}$ such that $y\neq x $, so you should $y\rightarrow x$. Then you arrive $f'(x)=0$ for all $x\in \Bbb{R}$, which gives $f$ is constant.
A: Late answer, but here is a slight generalization of this problem.
Let $X,Y\subseteq\mathbb{R}$ and suppose $f:X\to Y$ is a function. Suppose $f$ is $\alpha$-Holder continuous with $\alpha\in\mathbb{R}$ and $\alpha>1$. Then, there exists a $K\in\mathbb{R}$ such that for all $x,y\in X$, we have $|f(x)-f(y)|\leq K|x-y|^{\alpha}$. Now, consider $$0\leq \lim_{x\to y}\bigg|\frac{f(x)-f(y)}{x-y}\bigg|\leq \lim_{x\to y}K|x-y|^{\alpha-1} $$ Since $\alpha>1$, then $\alpha-1>0$, which implies $\lim\limits_{x\to y}|x-y|^{\alpha-1}=0$. By the squeeze theorem, we have $\lim\limits_{x\to y}\bigg|\frac{f(x)-f(y)}{x-y}\bigg|=0$ which implies $f'(x)=0$. Since the only functions whose derivatives are identically zero are the constant functions, then we must have $f(x)=c$ for some $c\in\mathbb{R}$.
