Man, your merge has very poor performance, because you are cloning the whole array twice inside a recursive function! Every merge call, even the ones with only one element on each side, will clone the whole array twice... You could try to make it in-place, just swapping elements.
Also, it is written like in C, it could be very improved using Rust constructs, like iterators, slices, and some trait magic.
Here it is one that's very good: dev.to/creativcoder/merge-k-sorted...
I specially like the one in the comments.
Hey, Thanks a lot for sharing the article, I'm still exploring Rust plus learning other things. I'm familiar with C so I was sort of seeing how it would be implemented in Rust Syntax.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Man, your
merge
has very poor performance, because you are cloning the whole array twice inside a recursive function! Everymerge
call, even the ones with only one element on each side, will clone the whole array twice... You could try to make it in-place, just swapping elements.Also, it is written like in C, it could be very improved using Rust constructs, like iterators, slices, and some trait magic.
Here it is one that's very good: dev.to/creativcoder/merge-k-sorted...
I specially like the one in the comments.
Hey, Thanks a lot for sharing the article, I'm still exploring Rust plus learning other things. I'm familiar with C so I was sort of seeing how it would be implemented in Rust Syntax.