I am studying algebraic geometry using Hartshorne's book, and in the lema 2.4 from chapter 3 we have that $(X,\mathscr O_X)$ is a ringed space, $\mathscr I$ is an injective $\mathscr O_X$-module, and that $\mathscr O_U$ is the sheaf $\mathscr O_X$ restrict to an open set $U\subset X$, and extended by zero outside $U$.
I understood the proof, but in the end of the proof he writes the equality $$Hom(\mathscr{O}_U,\mathscr{I})=\mathscr I(U),$$ and I can't see how to proof this.
Thanks in advance.
Giving an element in $\operatorname{Hom}(\mathcal{O}_U,\mathscr{I})$ is the same as giving maps $\mathcal{O}_U(V)\to \mathscr{I}(V)$ of $\mathcal{O}_U(V)$-modules, for every open $V\subset U$, which are compatible with restriction. But a morphism of $\mathcal{O}_U(V)$-modules $\mathcal{O}_U(V)\to \mathscr{I}(V)$ is uniquely determined by the image of $1_V\in \mathcal{O}_U(V)$ which is equal to $(1_U)|_V$. Hence, an element $\operatorname{Hom}(\mathcal{O}_U,\mathscr{I})$ is uniquely determined by the image of $1_U\in \mathcal{O}_U(U)$ under the map on global sections $\mathcal{O}_U(U)\to \mathscr{I}(U)$.