Only Rust has memory safe zero-copy collection that can be stored in a type 
(their slice type).

C++ and D can somewhat emulate that with ranges but I don't thing they have 
proper lifetime/escape analysis as you would need a borrow checker for that.

Nim has openarray, but it cannot be stored, you have an escape hatch in `ptr 
UncheckedArray[T]`.

If you are really concerned about zero-copy you should only use the `it` 
templates of `sequtils` (mapIt, foldIt and friends) and they would work with 
any `Indexable` type.

Also zero-copy and functional style of sequtils are usually at odds (though 
[zero-functional](https://github.com/zero-functional/zero-functional) helps a 
lot), if perf/allocation are really critical use a for loop.

Reply via email to