I'm wondering if this might not end up consuming a lot of memory for larger strings, due to the eager allocation scheme? I think it might be worth relocating if there is too much unused space. EG, if the array is, say at least 16 bytes long, and either uses less than 50% of its capacity, or has an excess of 4K?

```D
r = cast(immutable)buffer[0 .. buffer.length - tmpBuffer.length];
auto cap = buffer.capacity;
if (buffer.length* dstElementSizeOf >= 16 &&
        (r.length * 2 < cap || (cap - r.length) * dstElementSizeOf >= 4096) )
    r = r.idup;
```

It's a bit like readln's scheme I believe.