mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
builtins: Remove old incorrect comment about isSmallStr and add a test to make sure
This commit is contained in:
parent
bfc00a4b94
commit
32b815847e
1 changed files with 4 additions and 1 deletions
|
@ -215,11 +215,14 @@ pub const RocStr = extern struct {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: returns false for empty string!
|
|
||||||
pub fn isSmallStr(self: RocStr) bool {
|
pub fn isSmallStr(self: RocStr) bool {
|
||||||
return @bitCast(isize, self.str_capacity) < 0;
|
return @bitCast(isize, self.str_capacity) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "isSmallStr: returns true for empty string" {
|
||||||
|
try expect(isSmallStr(RocStr.empty()));
|
||||||
|
}
|
||||||
|
|
||||||
fn asArray(self: RocStr) [@sizeOf(RocStr)]u8 {
|
fn asArray(self: RocStr) [@sizeOf(RocStr)]u8 {
|
||||||
const as_ptr = @ptrCast([*]const u8, &self);
|
const as_ptr = @ptrCast([*]const u8, &self);
|
||||||
const slice = as_ptr[0..@sizeOf(RocStr)];
|
const slice = as_ptr[0..@sizeOf(RocStr)];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue