Skip to content

chore(std.mem): Rename trimLeft and trimRight to trimStart and trimEnd#23700

Merged
alexrp merged 2 commits intoziglang:masterfrom
sorairolake:rename-trims
May 12, 2025
Merged

chore(std.mem): Rename trimLeft and trimRight to trimStart and trimEnd#23700
alexrp merged 2 commits intoziglang:masterfrom
sorairolake:rename-trims

Conversation

@sorairolake
Copy link
Copy Markdown
Contributor

@sorairolake sorairolake commented Apr 27, 2025

Rename trimLeft to trimStart, and trimRight to trimEnd. trimLeft and trimRight functions remain as deprecated aliases for these new names.

Due to this change, these functions will do exactly what their names suggest in right-to-left scripts, just like in left-to-right scripts and non-string slices.

The new function names I suggested are inspired by JavaScript,12 C#,34 and Rust.56

Closes #23664

Footnotes

  1. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart

  2. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd

  3. https://learn.microsoft.com/en-us/dotnet/api/system.string.trimstart

  4. https://learn.microsoft.com/en-us/dotnet/api/system.string.trimend

  5. https://doc.rust-lang.org/std/primitive.str.html#method.trim_start

  6. https://doc.rust-lang.org/std/primitive.str.html#method.trim_end

Rename `trimLeft` to `trimStart`, and `trimRight` to `trimEnd`.
`trimLeft` and `trimRight` functions remain as deprecated aliases for
these new names.
Comment thread lib/std/mem.zig Outdated
@alexrp alexrp merged commit bc3c50c into ziglang:master May 12, 2025
16 of 18 checks passed
@sorairolake sorairolake deleted the rename-trims branch May 12, 2025 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: Rename mem.trimLeft and mem.trimRight to mem.trimStart and mem.trimEnd

3 participants