hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 78fb33bbef7478c0579f3ecdb8c96bec67846e66
parent 2219016e92afd3eea74af7d2c708c60d986e4dd7
Author: Sebastian <sebastian@sebsite.pw>
Date:   Thu,  5 May 2022 17:35:45 -0400

strio: clarify dynamic and string docs

The remark about the lifetime of the string buffer in the 'dynamic'
docstring was worded confusingly, and 'string' didn't mention whether
the return value was borrowed or allocated. The note about the buffer's
lifetime was moved from 'dynamic' to 'string'.

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mstrio/stream.ha | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/strio/stream.ha b/strio/stream.ha @@ -16,7 +16,9 @@ export type stream = struct { }; // Returns the current contents of the buffer as a string. Aborts the program if -// invalid UTF-8 has been written to the buffer. +// invalid UTF-8 has been written to the buffer. The return value is borrowed +// from the stream, and will be freed when the stream is closed. Use +// [[strings::dup]] to extend its lifetime. export fn string(in: *stream) str = { return strings::fromutf8(in.buf); }; @@ -65,9 +67,7 @@ const dynamic_vtable: io::vtable = io::vtable { // Creates a write-only string stream using an allocated buffer for storage, for // efficiently building strings. // -// Calling [[io::close]] on this stream will free the buffer. If stream's data -// is transfered via [[string]], it shouldn't be closed as long if the data is -// freed. +// Calling [[io::close]] on this stream will free the buffer. export fn dynamic() stream = { return stream { stream = &dynamic_vtable,