Context: I saw this solution, and as far as I can tell it uses the following: $$\int_{\gamma-i\infty}^{\gamma+i\infty}Q(s)/x^sds=\sum_{s_k\text{ poles of } Q}\text{Res}_{s=s_k}Q(s)/x^s+\int_{\gamma'-i\infty}^{\gamma'+i\infty}Q(s)/x^sds,\tag1$$ where $\Re(s)=\gamma$ lies to the right of all the poles $s_k$ and $\Re(s)=\gamma'$ lies to the left of all the poles, and $$Q(s)=\int_0^\infty x^{s-1}f(x)dx,$$ so that $$f(x)=\int_{\gamma-i\infty}^{\gamma+i\infty}Q(s)/x^sds.$$
Question: When, if ever, is $(1)$ true? I have not seen it discussed anywhere other than MSE, where I have seen it a few times without explanation or justification.
Pardon me if this question is trivial, I don't have much experience with complex analysis.