authorgravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2022-10-16 17:20:25+02:00
committergravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2022-12-09 21:57:17+01:00
log626e02a429218fd194111320057fc4f2e8ceecda
tree9a543138b06385ab5cecb3ec4aec53dce6e58c5f
parent6b7d9b34e8fcefa731800cef883c2400f9f39de5

docs: minor improvements


1 files changed, 7 insertions(+), 7 deletions(-)

lib/std/ascii.zig+7-7
...@@ -254,7 +254,7 @@ pub fn isLower(c: u8) bool {...@@ -254,7 +254,7 @@ pub fn isLower(c: u8) bool {
254 return inTable(c, tIndex.Lower);254 return inTable(c, tIndex.Lower);
255}255}
256256
257/// Returns whether the character has some graphical representation and can be printed.257/// Returns whether the character is printable and has some graphical representation.
258/// This also returns `true` for the space character.258/// This also returns `true` for the space character.
259/// This is the same as `!isControl(c)`.259/// This is the same as `!isControl(c)`.
260pub fn isPrint(c: u8) bool {260pub fn isPrint(c: u8) bool {
...@@ -286,7 +286,7 @@ pub fn isUpper(c: u8) bool {...@@ -286,7 +286,7 @@ pub fn isUpper(c: u8) bool {
286 return inTable(c, tIndex.Upper);286 return inTable(c, tIndex.Upper);
287}287}
288288
289/// Returns whether the character is a hexadecimal digit. This is case-insensitive.289/// Returns whether the character is a hexadecimal digit. Case-insensitive.
290pub fn isHex(c: u8) bool {290pub fn isHex(c: u8) bool {
291 return inTable(c, tIndex.Hex);291 return inTable(c, tIndex.Hex);
292}292}
...@@ -296,7 +296,7 @@ pub fn isASCII(c: u8) bool {...@@ -296,7 +296,7 @@ pub fn isASCII(c: u8) bool {
296 return c < 128;296 return c < 128;
297}297}
298298
299/// Uppercases the character and returns it as-is if it's already uppercased or not a letter.299/// Uppercases the character and returns it as-is if already uppercase or not a letter.
300pub fn toUpper(c: u8) u8 {300pub fn toUpper(c: u8) u8 {
301 if (isLower(c)) {301 if (isLower(c)) {
302 return c & 0b11011111;302 return c & 0b11011111;
...@@ -305,7 +305,7 @@ pub fn toUpper(c: u8) u8 {...@@ -305,7 +305,7 @@ pub fn toUpper(c: u8) u8 {
305 }305 }
306}306}
307307
308/// Lowercases the character and returns it as-is if it's already lowercased or not a letter.308/// Lowercases the character and returns it as-is if already lowercase or not a letter.
309pub fn toLower(c: u8) u8 {309pub fn toLower(c: u8) u8 {
310 if (isUpper(c)) {310 if (isUpper(c)) {
311 return c | 0b00100000;311 return c | 0b00100000;
...@@ -314,7 +314,7 @@ pub fn toLower(c: u8) u8 {...@@ -314,7 +314,7 @@ pub fn toLower(c: u8) u8 {
314 }314 }
315}315}
316316
317test "ascii character classes" {317test "ASCII character classes" {
318 const testing = std.testing;318 const testing = std.testing;
319319
320 try testing.expect(!isControl('a'));320 try testing.expect(!isControl('a'));
...@@ -440,7 +440,7 @@ pub fn startsWithIgnoreCase(haystack: []const u8, needle: []const u8) bool {...@@ -440,7 +440,7 @@ pub fn startsWithIgnoreCase(haystack: []const u8, needle: []const u8) bool {
440 return if (needle.len > haystack.len) false else eqlIgnoreCase(haystack[0..needle.len], needle);440 return if (needle.len > haystack.len) false else eqlIgnoreCase(haystack[0..needle.len], needle);
441}441}
442442
443test "ascii.startsWithIgnoreCase" {443test "startsWithIgnoreCase" {
444 try std.testing.expect(startsWithIgnoreCase("boB", "Bo"));444 try std.testing.expect(startsWithIgnoreCase("boB", "Bo"));
445 try std.testing.expect(!startsWithIgnoreCase("Needle in hAyStAcK", "haystack"));445 try std.testing.expect(!startsWithIgnoreCase("Needle in hAyStAcK", "haystack"));
446}446}
...@@ -449,7 +449,7 @@ pub fn endsWithIgnoreCase(haystack: []const u8, needle: []const u8) bool {...@@ -449,7 +449,7 @@ pub fn endsWithIgnoreCase(haystack: []const u8, needle: []const u8) bool {
449 return if (needle.len > haystack.len) false else eqlIgnoreCase(haystack[haystack.len - needle.len ..], needle);449 return if (needle.len > haystack.len) false else eqlIgnoreCase(haystack[haystack.len - needle.len ..], needle);
450}450}
451451
452test "ascii.endsWithIgnoreCase" {452test "endsWithIgnoreCase" {
453 try std.testing.expect(endsWithIgnoreCase("Needle in HaYsTaCk", "haystack"));453 try std.testing.expect(endsWithIgnoreCase("Needle in HaYsTaCk", "haystack"));
454 try std.testing.expect(!endsWithIgnoreCase("BoB", "Bo"));454 try std.testing.expect(!endsWithIgnoreCase("BoB", "Bo"));
455}455}