Distance calculations run in polynomial time, it can be slow if a lot of rows. You shouldn't be iterating manually. The function can take in a matrix. Say your input matrix has m rows and n columns, the distance matrix will be m by m.

m <- 100
n <- 5
dat <- matrix(rnorm(m*n), nrow=m)
distout <- as.matrix(dist(dat))
dim(distout)
#> [1] 100 100

^{Created on 2020-08-03 by the reprex package (v0.3.0)}

In my case I have to iterate over rows. do you know anything about the use of "sweep" function with euclidean distance? I understand that it might be faster but I don't know how to implement this.

You can decompose your frame into numeric part and character part.
use caret dummyVars function to one hot encode the character part so that dist() can be applied to it.
Either recombine the dummyvars with the numerics and dist the whole set, or run dist twice and add the results (the latter demo'd below)