let sub t ~index ~length =
if length = 0 then Some empty else
begin
let lgth = S.length t in
if lgth = 0
then None (* `length <> 0` *)
else begin
try
let res = make length (S.get t index) in
for i = 1 to length - 1 do
S.set res i (S.get t (index + i))
done;
Some res
with _ -> None
end
end