mirror of
https://github.com/ziglang/zig.git
synced 2026-10-14 10:27:43 -04:00
chore(std.mem): Rename trimLeft and trimRight
Rename `trimLeft` to `trimStart`, and `trimRight` to `trimEnd`. `trimLeft` and `trimRight` functions remain as deprecated aliases for these new names.
This commit is contained in:
1 parent
3783b1b23c
commit
5fc4448e45
22 files changed
+61
-47
No files matched your search
@@ -140,7 +140,7 @@ const Block = struct {
|
||||
/// (e.g. for a blockquote, this would be everything except the leading
|
||||
/// `>`). If unsuccessful, returns null.
|
||||
fn match(b: Block, line: []const u8) ?[]const u8 {
|
||||
const unindented = mem.trimLeft(u8, line, " \t");
|
||||
const unindented = mem.trimStart(u8, line, " \t");
|
||||
const indent = line.len - unindented.len;
|
||||
return switch (b.tag) {
|
||||
.list => line,
|
||||
@@ -156,7 +156,7 @@ const Block = struct {
|
||||
.table_row => null,
|
||||
.heading => null,
|
||||
.code_block => code_block: {
|
||||
const trimmed = mem.trimRight(u8, unindented, " \t");
|
||||
const trimmed = mem.trimEnd(u8, unindented, " \t");
|
||||
if (mem.indexOfNone(u8, trimmed, "`") != null or trimmed.len != b.data.code_block.fence_len) {
|
||||
const effective_indent = @min(indent, b.data.code_block.indent);
|
||||
break :code_block line[effective_indent..];
|
||||
@@ -225,7 +225,7 @@ pub fn feedLine(p: *Parser, line: []const u8) Allocator.Error!void {
|
||||
p.pending_blocks.items.len > 0 and
|
||||
p.pending_blocks.getLast().tag == .paragraph)
|
||||
{
|
||||
try p.addScratchStringLine(mem.trimLeft(u8, rest_line, " \t"));
|
||||
try p.addScratchStringLine(mem.trimStart(u8, rest_line, " \t"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ pub fn feedLine(p: *Parser, line: []const u8) Allocator.Error!void {
|
||||
last_pending_block.canAccept()
|
||||
else
|
||||
.blocks;
|
||||
const rest_line_trimmed = mem.trimLeft(u8, rest_line, " \t");
|
||||
const rest_line_trimmed = mem.trimStart(u8, rest_line, " \t");
|
||||
switch (can_accept) {
|
||||
.blocks => {
|
||||
// If we're inside a list item and the rest of the line is blank, it
|
||||
@@ -500,7 +500,7 @@ fn appendBlockStart(p: *Parser, block_start: BlockStart) !void {
|
||||
}
|
||||
|
||||
fn startBlock(p: *Parser, line: []const u8) !?BlockStart {
|
||||
const unindented = mem.trimLeft(u8, line, " \t");
|
||||
const unindented = mem.trimStart(u8, line, " \t");
|
||||
const indent = line.len - unindented.len;
|
||||
if (isThematicBreak(line)) {
|
||||
// Thematic breaks take precedence over list items.
|
||||
|
||||
Reference in new issue
Block a user