Use the dist() function, but you need to form a matrix from the two inputs for the first argument to dist():
dist(rbind(x1, x2))
For the input in the OP's question we get:
> dist(rbind(x1, x2))
x1
x2 7.94821
a single value that is the Euclidean distance between x1 and x2.