Sorry I misread (lacking sleep). I can just re slice from the slice, silly me.

import std.stdio;

void extendSlice(T)(ref T[] slice, uint extendCount)
{
    slice = slice.ptr[0..slice.length+extendCount];
}

void main()
{
    char[] a = "Hello".dup;
    char[] b;
    b = a[1..3]; //b is a view into a
    writeln(a); //(Hello)
    writeln(b); //(el)
    extendSlice(b,1);
    writeln(a); //(Hello)
    writeln(b); //(ell)
}

Reply via email to