How to remove footnote separator underneath table

\documentclass[a4paper,12pt]{book}

\usepackage{booktabs}
\usepackage[hang,flushmargin]{footmisc}

\begin{document}

\begin{table}[h]
\begin{minipage}{\linewidth}
\renewcommand\footnoterule{}
\begin{tabular}{@{}lrr@{}}
\toprule
A    & B     & C     \\ \midrule
Text & 123   & 123   \\
Text & 123\footnote{An interesting footnote.} & 123 \\
Text & 123   & 123   \\ \midrule
Text & 12345 & 12345 \\ \bottomrule
\end{tabular}
\end{minipage}
\end{table}

test\footnote{An interesting footnote.}
\end{document}

A more automatic solution, not requiring adding code inside each applicable minipage.

The \InFloat test is borrowed from How can I detect if I'm inside or outside of a float environment?

This renews the \footnoterule command after the end of a tabular only if it's inside a floating environment.

\documentclass[a4paper,12pt]{book}

\usepackage{booktabs}
\usepackage[hang,flushmargin]{footmisc}

\makeatletter
\newcommand\InFloat[2]{\@ifundefined{@captype}{#2}{#1}}
\makeatother
\usepackage{etoolbox}
\AfterEndEnvironment{tabular}{\InFloat{\renewcommand\footnoterule{}}{}}

\begin{document}

\begin{table}[h]
\begin{minipage}{\linewidth}
\begin{tabular}{@{}lrr@{}}
\toprule
A    & B     & C     \\ \midrule
Text & 123   & 123   \\
Text & 123\footnote{An interesting footnote.} & 123 \\
Text & 123   & 123   \\ \midrule
Text & 12345 & 12345 \\ \bottomrule
\end{tabular}
\end{minipage}
\end{table}

Test.\footnote{An interesting footnote.}

\bigskip

\begin{minipage}{\linewidth}
Test.\footnote{An interesting footnote.}
\end{minipage}
\end{document}

enter image description here