Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing Format.pp_print_bytes function. #10430

Merged
merged 1 commit into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ Working version
- #10389, #10391, #10392: Add {Int,Int32,Int64,Nativeint}.{min,max}.
(Nicolás Ojeda Bär and Alain Frisch, review by Xavier Leroy)

- #10430: Add Format.print_bytes and Format.pp_print_bytes.
(Gabriel Radanne, review by Gabriel Scherer and David Allsopp)

### Other libraries:

- #10047: Add `Unix.realpath`
Expand Down
2 changes: 2 additions & 0 deletions stdlib/.depend
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ stdlib__Format.cmo : format.ml \
stdlib__Either.cmi \
camlinternalFormatBasics.cmi \
camlinternalFormat.cmi \
stdlib__Bytes.cmi \
stdlib__Buffer.cmi \
stdlib__Format.cmi
stdlib__Format.cmx : format.ml \
Expand All @@ -291,6 +292,7 @@ stdlib__Format.cmx : format.ml \
stdlib__Either.cmx \
camlinternalFormatBasics.cmx \
camlinternalFormat.cmx \
stdlib__Bytes.cmx \
stdlib__Buffer.cmx \
stdlib__Format.cmi
stdlib__Format.cmi : format.mli \
Expand Down
3 changes: 3 additions & 0 deletions stdlib/format.ml
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,8 @@ let pp_print_as state isize s =
let pp_print_string state s =
pp_print_as state (String.length s) s

let pp_print_bytes state s =
pp_print_as state (Bytes.length s) (Bytes.to_string s)

(* To format an integer. *)
let pp_print_int state i = pp_print_string state (Int.to_string i)
Expand Down Expand Up @@ -1114,6 +1116,7 @@ and open_stag = pp_open_stag std_formatter
and close_stag = pp_close_stag std_formatter
and print_as = pp_print_as std_formatter
and print_string = pp_print_string std_formatter
and print_bytes = pp_print_bytes std_formatter
and print_int = pp_print_int std_formatter
and print_float = pp_print_float std_formatter
and print_char = pp_print_char std_formatter
Expand Down
6 changes: 6 additions & 0 deletions stdlib/format.mli
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ val pp_print_string : formatter -> string -> unit
val print_string : string -> unit
(** [pp_print_string ppf s] prints [s] in the current pretty-printing box. *)

val pp_print_bytes : formatter -> bytes -> unit
val print_bytes : bytes -> unit
(** [pp_print_bytes ppf b] prints [b] in the current pretty-printing box.
@since 4.13.0
*)

val pp_print_as : formatter -> int -> string -> unit
val print_as : int -> string -> unit
(** [pp_print_as ppf len s] prints [s] in the current pretty-printing box.
Expand Down