~sircmpwn/hare-users

1

How to represent stream as []u8

Details
Message ID
<CADVGtmv-hNNtPLf0F1mA-K8TuxW2CcfUKJQEALuTAHu6LMJDHw@mail.gmail.com>
DKIM signature
pass
Download raw message
Hello! Thanks for help, but I have new problem.
I can't figure out how to represent stream as u8.

Here is my example:

use fmt;
use io;
use bufio;
use memio;
use os;
use fs;
use strings;

export fn main() void = {

   let buf = memio::dynamic();

   for(let i=0z; i < 5; i +=3) {
      let name = readLine();
      fmt::printfln("You entered: {}", name)!;
      io::write(&buf, strings::toutf8(name))!;
   };

   let res = strings::fromutf8(buf);
   //  error: Argument type memio::stream is not assignable to
parameter type []u8
};

fn readLine() str = {
   fmt::println("Enter string:")!;
   const line = bufio::read_line(os::stdin)! as []u8;
   return strings::fromutf8(line)! ;
};
Details
Message ID
<CYR8Q4D1TPA4.NSYOFTRPBXCV@taiga>
In-Reply-To
<CADVGtmv-hNNtPLf0F1mA-K8TuxW2CcfUKJQEALuTAHu6LMJDHw@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
You can use memio::buffer to get the stream contents as []u8.
Reply to thread Export thread (mbox)