I have a slice that I want to replicate. For example, if xs = [1, 2, 3]
, and I need to replicate it 4 times, I would end up with ys = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]
.
In Haskell, I would do something like this:
ys = take (4 * length xs) $ cycle xs
How might this be similarly done in Rust?