add CCByte_buffer.to_slice

This commit is contained in:
Simon Cruanes 2024-05-13 21:52:46 -04:00
parent c29083c216
commit f5aa4de6e7
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 5 additions and 0 deletions

View file

@ -89,6 +89,7 @@ let[@inline] contents self = Bytes.sub_string self.bs 0 self.len
let[@inline] contents_bytes self = Bytes.sub self.bs 0 self.len let[@inline] contents_bytes self = Bytes.sub self.bs 0 self.len
let[@inline] append_iter self i = i (add_char self) let[@inline] append_iter self i = i (add_char self)
let[@inline] append_seq self seq = Seq.iter (add_char self) seq let[@inline] append_seq self seq = Seq.iter (add_char self) seq
let[@inline] to_slice self = CCByte_slice.create ~len:self.len self.bs
let fold_left f acc self = let fold_left f acc self =
let { bs; len } = self in let { bs; len } = self in

View file

@ -65,6 +65,10 @@ val unsafe_get : t -> int -> char
val set : t -> int -> char -> unit val set : t -> int -> char -> unit
val unsafe_set : t -> int -> char -> unit val unsafe_set : t -> int -> char -> unit
val to_slice : t -> CCByte_slice.t
(** [to_slice buf] returns a slice of the current content.
The slice shares the same byte array as [buf] (until [buf] is resized). *)
val contents : t -> string val contents : t -> string
(** Copy the internal data to a string. Allocates. *) (** Copy the internal data to a string. Allocates. *)