Use `break` to leave a loop or a labeled block; either can produce a value. Labels also distinguish exits from nested blocks. section 4.1.3
Listing 4.1 Counting the dictionary words
fn countWordlist(text: []const u8) usize {
var count: usize = 0;
var word_iter = std.mem.tokenizeScalar(u8, text, '\n'); #1
while (word_iter.next()) |_| { #2
count += 1;
}
return count;
}
A labeled block returns either 0 or 1, with deferred resource cleanup kept in the block’s scope. section 4.1.3
Listing 4.2 Comptime type parameters for fun and profit
pub fn tokenizeScalar(
comptime T: type, #1
buffer: []const T, #2
delimiter: T, #3
) TokenIterator(T, .scalar) #4
A labeled block raises the compile-time branch quota, then exits with the parsed embedded wordlist. section 4.1.3







