let take_while_with_index t ~f =     let buf = Buffer.create (length t) in     let rec loop idx =       match get t idx with       | Some c when f idx c -> Buffer.add_char buf c; loop (idx + 1)       | _ -> ()     in     loop 0;     B.of_buffer buf