let to_list ~line_width ~indent t =
let res = ref [] in
let add c = res := c :: !res in
SmartPrint.to_something line_width indent
(fun c -> `Char c |> add)
(fun s -> `String s |> add)
(fun s ofs len -> `Sub_string (s, ofs, len) |> add)
t;
List.rev !res