mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
@@ -154,10 +154,21 @@ pub const MutableString = struct {
|
||||
return self.list.toOwnedSlice(self.allocator);
|
||||
}
|
||||
|
||||
pub fn toOwnedSliceLeaky(self: *MutableString) string {
|
||||
pub fn toOwnedSliceLeaky(self: *MutableString) []u8 {
|
||||
return self.list.items;
|
||||
}
|
||||
|
||||
pub fn toOwnedSentinelLeaky(self: *MutableString) [:0]u8 {
|
||||
if (self.list.items.len > 0 and self.list.items[self.list.items.len - 1] != 0) {
|
||||
self.list.append(
|
||||
self.allocator,
|
||||
0,
|
||||
) catch unreachable;
|
||||
}
|
||||
|
||||
return self.list.items[0 .. self.list.items.len - 1 :0];
|
||||
}
|
||||
|
||||
pub fn toOwnedSliceLength(self: *MutableString, length: usize) string {
|
||||
self.list.shrinkAndFree(self.allocator, length);
|
||||
return self.list.toOwnedSlice(self.allocator);
|
||||
|
||||
Reference in New Issue
Block a user