A simple way to find the rotation matrix is using a geometric approach.
In 2D you can express a vector $(r, \theta)$ (in polar coordinates) in cartesian basis $(e_x, e_y)$ as:
$$v' = r \cos \alpha \ e_x + r \sin \alpha \ e_y$$
$r = \|v'\|$
$\alpha = \cos^{-1}(\frac{v' \cdot e_x}{r})$
Since $e_y$ is a 90 degree rotation of $e_x$ we can rewrite the vector as:
$$v' = r \cos \alpha \ e_x + r \sin \alpha
\ R_{90} e_x$$
Where $R_{90}$ is a rotation matrix that rotates a vector 90 degrees.
Now, instead of expressing $v'$ in the canonical basis $(e_x, e_y)$ we can change the basis to other orthonormal basis, say $(v, R_{90} v)$. Assumming $r = 1$.
$$v' = \cos \theta \ v + \sin \theta
\ R_{90} v$$
Where
$\theta = \cos^{-1}(v' \cdot v)$
In 3D one can do the same.
$$v' = \cos \theta \ v + \sin \theta \ \frac{(v \times v') \times v}{\|v \times v'\|}$$
We can simplify this since:
$\cos \theta = v' \cdot v$
$\sin \theta = \|v \times v'\|$
Then
$$v' = (v' \cdot v) \ v + (v \times v') \times v$$
We can express in matrix form as:
$$v' = ((v' \cdot v) \ I + [v \times v']_{\times}) v$$
Where $I$ is the identity matrix and $[v \times v']_{\times}$ is the cross product matrix of the vector $v \times v'$. So we can write:
$$v' = R v$$
$$R = (v' \cdot v) \ I + [v \times v']_{\times}$$
And that is the rotation matrix you are looking for. Just need to compute one dot product and one cross product of the input unit vectors. No need to compute $\sin$ and $\cos$ explicitly.
The above expression agrees with the Euler-Rodrigues formula i.e., the Euler-Rodrigues reduces to the formula we derived when $v$ and $v'$ are two vectors in the same plane i.e., orthogonal to the rotation axis (see https://en.m.wikipedia.org/wiki/Euler%E2%80%93Rodrigues_formula)
The Euler-Rodrigues formula is the folowing:
$$v' = v + 2 a \ w \times v + 2 \ w \times (w \times v)$$
Where in our case:
$a = \cos \frac{\theta}{2}$
$w = \sin \frac{\theta}{2} \ \frac{v \times v'}{\|v \times v'\|}$
If you replace those $a$ and $w$ and apply some trig identities you will get the expression we derived.
If you are familiar with quaternions you will find this familiar as the parameter for Euler-Rodrigues formula agree with unit quaternion's components.