tobogganSe connecter

louise

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

35 lignes · 906 octetsBrut · Historique
1// Standard input as bytes (ADR 0086), from stdin_bytes.stdin: after a
2// line, chunks of at most the size asked, any bytes (NUL, 0xff), then the
3// end. A size below one reads one byte.
4
5import std/bytes
6import std/io
7
8fn shown :: r: Result<Option<Bytes>, io.Error> -> String
9{
10 match r
11 { Ok(Some(b)) -> "bytes " <> debug b
12 , Ok(None) -> "end"
13 , Error(e) -> "error " <> show e
14 }
15}
16
17pub fn main :: -> () / <io>
18{
19 match io.read_line ()
20 { Ok(Some(line)) -> io.println ("line " <> debug line)
21 , _ -> io.println "no line"
22 }
23 io.println (shown (io.read_bytes 4))
24 io.println (shown (io.read_bytes 0))
25 io.println (shown (io.read_bytes 100))
26 io.println (shown (io.read_bytes 100))
27 match io.read_line ()
28 { Ok(None) -> io.println "line: end", _ -> io.println "line: more?" }
29}
30//> line "line one"
31//> bytes b"rest"
32//> bytes b":"
33//> bytes b" \x00\x01\xff and more"
34//> end
35//> line: end