From 545a8871ec8ee754a9930479b04746c45e76a872 Mon Sep 17 00:00:00 2001 From: Carlos Une Date: Mon, 17 Oct 2022 23:24:57 -0300 Subject: [PATCH] Update the tutorial to match `strings::fromutf8` new behavior Reference: https://lists.sr.ht/~sircmpwn/hare-users/%3CCNI4NNE8ZOML.F9S79ROU6DA5%40taiga%3E Signed-off-by: Carlos Une --- content/tutorials/introduction.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/content/tutorials/introduction.md b/content/tutorials/introduction.md index 4f9f4a0..024728f 100644 --- a/content/tutorials/introduction.md +++ b/content/tutorials/introduction.md @@ -125,7 +125,7 @@ sections: fn askname() str = { fmt::println("Hello! Please enter your name:")!; const name = bufio::scanline(os::stdin)! as []u8; - return strings::fromutf8(name); + return strings::fromutf8(name)!; }; // Greets a user by name. @@ -172,7 +172,7 @@ sections: fn askname() str = { fmt::println("Hello! Please enter your name:")!; const name = bufio::scanline(os::stdin)! as []u8; - return strings::fromutf8(name); + return strings::fromutf8(name)!; }; // Greets a user by name. @@ -230,7 +230,7 @@ sections: // Example A const source = os::open("main.ha")!; const source = io::drain(source)!; - const source = strings::fromutf8(source); + const source = strings::fromutf8(source)!; const source = strings::split(source, "\n"); first3(source); @@ -661,7 +661,7 @@ sections: defer io::close(file)!; const buffer = io::drain(file)!; // Allocates buffer defer free(buffer); - const string = strings::fromutf8(buffer); // Borrows buffer + const string = strings::fromutf8(buffer)!; // Borrows buffer fmt::print(string)!; }; details: | @@ -917,7 +917,7 @@ sections: case io::EOF => return unexpectedeof; case let buf: []u8 => - yield strings::fromutf8(buf); + yield strings::fromutf8(buf)!; }; defer free(num); return strconv::stou(num)?; @@ -1541,7 +1541,7 @@ sections: case io::EOF => break; }; - append(lines, strings::fromutf8(line)); + append(lines, strings::fromutf8(line)!); }; insert(lines[0], strings::dup("test line")); @@ -1605,7 +1605,7 @@ sections: case io::EOF => break; }; - static append(lines, strings::fromutf8(line)); + static append(lines, strings::fromutf8(line)!); }; static insert(lines[0], strings::dup("test line")); @@ -1781,7 +1781,7 @@ sections: const file = os::open("main.ha")!; defer io::close(file)!; const data = io::drain(file)!; - src = strings::fromutf8(data); + src = strings::fromutf8(data)!; }; @fini fn fini() void = { -- 2.45.2