The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add String.of_char (#14440)

* Add String.of_char

* Promote partiality.ml test

* Update changes

authored by

Daniel Bünzli and committed by
GitHub
70885095 c7574991

+27 -5
+3
Changes
··· 133 133 134 134 ### Standard library: 135 135 136 + - #14440: Add String.of_char 137 + (Daniel Bünzli, review by Nicolás Ojeda Bär and Gabriel Scherer) 138 + 136 139 - #14362: Add String.{drop,take,cut}_{first,last}_while 137 140 (Daniel Bünzli, review by Nicolás Ojeda Bär and David Allsopp) 138 141
+1
stdlib/string.ml
··· 37 37 let init n f = 38 38 B.init n f |> bts 39 39 let empty = "" 40 + let of_char c = make 1 c 40 41 let of_bytes = B.to_string 41 42 let to_bytes = B.of_string 42 43 let sub s ofs len =
+6
stdlib/string.mli
··· 103 103 104 104 @raise Invalid_argument if [i] not an index of [s]. *) 105 105 106 + val of_char : char -> string 107 + (** [of_char c] is [c] as a string. 108 + 109 + @since 5.5 110 + *) 111 + 106 112 val of_bytes : bytes -> string 107 113 (** Return a new string that contains the same bytes as the given byte 108 114 sequence.
+6
stdlib/stringLabels.mli
··· 103 103 104 104 @raise Invalid_argument if [i] not an index of [s]. *) 105 105 106 + val of_char : char -> string 107 + (** [of_char c] is [c] as a string. 108 + 109 + @since 5.5 110 + *) 111 + 106 112 val of_bytes : bytes -> string 107 113 (** Return a new string that contains the same bytes as the given byte 108 114 sequence.
+6
testsuite/tests/lib-string/test_string.ml
··· 252 252 assert (String.cut_last_while Char.Ascii.is_white "abc" = ("abc", "")); 253 253 assert (String.cut_last_while Char.Ascii.is_white "abc " = ("abc", " ")); 254 254 () 255 + 256 + let () = 257 + (* Test String.of_char *) 258 + assert (String.of_char 'a' = "a"); 259 + assert (String.of_char '\x00' = "\x00"); 260 + ()
+5 -5
testsuite/tests/match-side-effects/partiality.ml
··· 408 408 (switch* t2/0 409 409 case tag 0: (exit 31) 410 410 case tag 1: 411 - (apply (field_imm 9 (global Stdlib__String!)) 411 + (apply (field_imm 10 (global Stdlib__String!)) 412 412 (field_imm 0 t1/0) (field_imm 0 t2/0)) 413 413 case tag 2: (exit 36) 414 414 case tag 3: (exit 36)) ··· 418 418 case tag 0: (exit 31) 419 419 case tag 1: (exit 31) 420 420 case tag 2: 421 - (apply (field_imm 9 (global Stdlib__String!)) (field_imm 0 t1/0) 422 - (field_imm 0 t2/0)) 421 + (apply (field_imm 10 (global Stdlib__String!)) 422 + (field_imm 0 t1/0) (field_imm 0 t2/0)) 423 423 case tag 3: -1) 424 424 case tag 3: 425 425 (switch* t2/0 ··· 427 427 case tag 1: (exit 31) 428 428 case tag 2: 1 429 429 case tag 3: 430 - (apply (field_imm 9 (global Stdlib__String!)) (field_imm 0 t1/0) 431 - (field_imm 0 t2/0)))) 430 + (apply (field_imm 10 (global Stdlib__String!)) 431 + (field_imm 0 t1/0) (field_imm 0 t2/0)))) 432 432 with (31) (switch* t2/0 case tag 0: 1 433 433 case tag 1: 1)))) 434 434 (apply (field_mut 1 (global Toploop!)) "compare" compare/0))