Rope.leafFrom

Get a leaf node that is a subrope starting with the given index. The length of the node may vary, and does not have to reach the end of the rope.

struct Rope
const nothrow
leafFrom
(
size_t start
)
out (r; r.isLeaf)

Examples

auto myRope = Rope(
    Rope("Hello, "),
    Rope(
        Rope("Flu"),
        Rope("id"),
    ),
);

assert(myRope.leafFrom(0) == Rope("Hello, "));
assert(myRope.leafFrom(7) == Rope("Flu"));
assert(myRope.leafFrom(10) == Rope("id"));

assert(myRope.leafFrom(2) == Rope("llo, "));
assert(myRope.leafFrom(7) == Rope("Flu"));
assert(myRope.leafFrom(8) == Rope("lu"));
assert(myRope.leafFrom(9) == Rope("u"));

assert(myRope.leafFrom(myRope.length) == Rope.init);

Meta