I add two little answers with an addendum:
1st proposal:

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[f\colon X\overset{\raise-.5ex\hbox{$\sim$}}{\longrightarrow}Y\]
\end{document}
2nd proposal:
Using tikz-cd package:

\documentclass[12pt]{article}
\usepackage{tikz-cd,relsize}
\tikzset{close/.style={outer sep=-1.2pt}}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\[\begin{tikzcd}[column sep=.3in]
f: X \arrow[r, close,"\mathlarger{\sim}"] & Y
\end{tikzcd}\]
\lipsum[2]
\end{document}
Addendum of the 2020/04/29: Using stix font where exists a specific symbol named \similarrightarrow. But there is an inconvenience. The stix font change the fonts of the characters and you not have the CM default font.
\documentclass[a4paper,12pt]{article}
\usepackage{mathtools,amssymb}
\usepackage{stix}
\begin{document}
\[f\colon X \similarrightarrow Y\]
\end{document}

\xrightarrow{\,\raisebox{-0.4ex}{$\sim$}\,}. – Mar 21 '19 at 18:12\raisebox{-.4ex}[0ex][0ex]{$\sim$}– Sandy G Mar 21 '19 at 19:57