Skip to content

Commit

Permalink
Rename trimLeft to trimStart and trimRight to trimEnd
Browse files Browse the repository at this point in the history
  • Loading branch information
Hasnep committed Jun 19, 2023
1 parent d10d71c commit 97fa675
Show file tree
Hide file tree
Showing 16 changed files with 110 additions and 110 deletions.
4 changes: 2 additions & 2 deletions crates/compiler/builtins/bitcode/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ comptime {
exportStrFn(str.fromUtf8RangeC, "from_utf8_range");
exportStrFn(str.repeat, "repeat");
exportStrFn(str.strTrim, "trim");
exportStrFn(str.strTrimLeft, "trim_left");
exportStrFn(str.strTrimRight, "trim_right");
exportStrFn(str.strTrimStart, "trim_start");
exportStrFn(str.strTrimEnd, "trim_end");
exportStrFn(str.strCloneTo, "clone_to");
exportStrFn(str.withCapacity, "with_capacity");
exportStrFn(str.strGraphemes, "graphemes");
Expand Down
44 changes: 22 additions & 22 deletions crates/compiler/builtins/bitcode/src/str.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2302,7 +2302,7 @@ pub fn strTrim(input_string: RocStr) callconv(.C) RocStr {
}
}

pub fn strTrimLeft(input_string: RocStr) callconv(.C) RocStr {
pub fn strTrimStart(input_string: RocStr) callconv(.C) RocStr {
var string = input_string;

if (string.isEmpty()) {
Expand Down Expand Up @@ -2350,7 +2350,7 @@ pub fn strTrimLeft(input_string: RocStr) callconv(.C) RocStr {
}
}

pub fn strTrimRight(input_string: RocStr) callconv(.C) RocStr {
pub fn strTrimEnd(input_string: RocStr) callconv(.C) RocStr {
var string = input_string;

if (string.isEmpty()) {
Expand Down Expand Up @@ -2583,22 +2583,22 @@ test "strTrim: small to small" {
try expect(trimmed.isSmallStr());
}

test "strTrimLeft: empty" {
const trimmedEmpty = strTrimLeft(RocStr.empty());
test "strTrimStart: empty" {
const trimmedEmpty = strTrimStart(RocStr.empty());
try expect(trimmedEmpty.eq(RocStr.empty()));
}

test "strTrimLeft: blank" {
test "strTrimStart: blank" {
const original_bytes = " ";
const original = RocStr.init(original_bytes, original_bytes.len);
defer original.decref();

const trimmed = strTrimLeft(original);
const trimmed = strTrimStart(original);

try expect(trimmed.eq(RocStr.empty()));
}

test "strTrimLeft: large to large" {
test "strTrimStart: large to large" {
const original_bytes = " hello even more giant world ";
const original = RocStr.init(original_bytes, original_bytes.len);
defer original.decref();
Expand All @@ -2611,12 +2611,12 @@ test "strTrimLeft: large to large" {

try expect(!expected.isSmallStr());

const trimmed = strTrimLeft(original);
const trimmed = strTrimStart(original);

try expect(trimmed.eq(expected));
}

test "strTrimLeft: large to small" {
test "strTrimStart: large to small" {
// `original` will be consumed by the concat; do not free explicitly
const original_bytes = " hello ";
const original = RocStr.init(original_bytes, original_bytes.len);
Expand All @@ -2629,14 +2629,14 @@ test "strTrimLeft: large to small" {

try expect(expected.isSmallStr());

const trimmed = strTrimLeft(original);
const trimmed = strTrimStart(original);
defer trimmed.decref();

try expect(trimmed.eq(expected));
try expect(!trimmed.isSmallStr());
}

test "strTrimLeft: small to small" {
test "strTrimStart: small to small" {
const original_bytes = " hello ";
const original = RocStr.init(original_bytes, original_bytes.len);
defer original.decref();
Expand All @@ -2649,28 +2649,28 @@ test "strTrimLeft: small to small" {

try expect(expected.isSmallStr());

const trimmed = strTrimLeft(original);
const trimmed = strTrimStart(original);

try expect(trimmed.eq(expected));
try expect(trimmed.isSmallStr());
}

test "strTrimRight: empty" {
const trimmedEmpty = strTrimRight(RocStr.empty());
test "strTrimEnd: empty" {
const trimmedEmpty = strTrimEnd(RocStr.empty());
try expect(trimmedEmpty.eq(RocStr.empty()));
}

test "strTrimRight: blank" {
test "strTrimEnd: blank" {
const original_bytes = " ";
const original = RocStr.init(original_bytes, original_bytes.len);
defer original.decref();

const trimmed = strTrimRight(original);
const trimmed = strTrimEnd(original);

try expect(trimmed.eq(RocStr.empty()));
}

test "strTrimRight: large to large" {
test "strTrimEnd: large to large" {
const original_bytes = " hello even more giant world ";
const original = RocStr.init(original_bytes, original_bytes.len);
defer original.decref();
Expand All @@ -2683,12 +2683,12 @@ test "strTrimRight: large to large" {

try expect(!expected.isSmallStr());

const trimmed = strTrimRight(original);
const trimmed = strTrimEnd(original);

try expect(trimmed.eq(expected));
}

test "strTrimRight: large to small" {
test "strTrimEnd: large to small" {
// `original` will be consumed by the concat; do not free explicitly
const original_bytes = " hello ";
const original = RocStr.init(original_bytes, original_bytes.len);
Expand All @@ -2701,14 +2701,14 @@ test "strTrimRight: large to small" {

try expect(expected.isSmallStr());

const trimmed = strTrimRight(original);
const trimmed = strTrimEnd(original);
defer trimmed.decref();

try expect(trimmed.eq(expected));
try expect(!trimmed.isSmallStr());
}

test "strTrimRight: small to small" {
test "strTrimEnd: small to small" {
const original_bytes = " hello ";
const original = RocStr.init(original_bytes, original_bytes.len);
defer original.decref();
Expand All @@ -2721,7 +2721,7 @@ test "strTrimRight: small to small" {

try expect(expected.isSmallStr());

const trimmed = strTrimRight(original);
const trimmed = strTrimEnd(original);

try expect(trimmed.eq(expected));
try expect(trimmed.isSmallStr());
Expand Down
12 changes: 6 additions & 6 deletions crates/compiler/builtins/roc/Str.roc
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ interface Str
startsWith,
endsWith,
trim,
trimLeft,
trimRight,
trimStart,
trimEnd,
toDec,
toF64,
toF32,
Expand Down Expand Up @@ -448,15 +448,15 @@ trim : Str -> Str

## Return the [Str] with all whitespace removed from the beginning.
## ```
## expect Str.trimLeft " Hello \n\n" == "Hello \n\n"
## expect Str.trimStart " Hello \n\n" == "Hello \n\n"
## ```
trimLeft : Str -> Str
trimStart : Str -> Str

## Return the [Str] with all whitespace removed from the end.
## ```
## expect Str.trimRight " Hello \n\n" == " Hello"
## expect Str.trimEnd " Hello \n\n" == " Hello"
## ```
trimRight : Str -> Str
trimEnd : Str -> Str

## Encode a [Str] to a [Dec]. A [Dec] value is a 128-bit decimal
## [fixed-point number](https://en.wikipedia.org/wiki/Fixed-point_arithmetic).
Expand Down
4 changes: 2 additions & 2 deletions crates/compiler/builtins/src/bitcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ pub const STR_TO_UTF8: &str = "roc_builtins.str.to_utf8";
pub const STR_FROM_UTF8_RANGE: &str = "roc_builtins.str.from_utf8_range";
pub const STR_REPEAT: &str = "roc_builtins.str.repeat";
pub const STR_TRIM: &str = "roc_builtins.str.trim";
pub const STR_TRIM_LEFT: &str = "roc_builtins.str.trim_left";
pub const STR_TRIM_RIGHT: &str = "roc_builtins.str.trim_right";
pub const STR_TRIM_START: &str = "roc_builtins.str.trim_start";
pub const STR_TRIM_END: &str = "roc_builtins.str.trim_end";
pub const STR_GET_UNSAFE: &str = "roc_builtins.str.get_unsafe";
pub const STR_RESERVE: &str = "roc_builtins.str.reserve";
pub const STR_APPEND_SCALAR: &str = "roc_builtins.str.append_scalar";
Expand Down
4 changes: 2 additions & 2 deletions crates/compiler/can/src/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ map_symbol_to_lowlevel_and_arity! {
StrToUtf8; STR_TO_UTF8; 1,
StrRepeat; STR_REPEAT; 2,
StrTrim; STR_TRIM; 1,
StrTrimLeft; STR_TRIM_LEFT; 1,
StrTrimRight; STR_TRIM_RIGHT; 1,
StrTrimStart; STR_TRIM_START; 1,
StrTrimEnd; STR_TRIM_END; 1,
StrToScalars; STR_TO_SCALARS; 1,
StrGetUnsafe; STR_GET_UNSAFE; 2,
StrSubstringUnsafe; STR_SUBSTRING_UNSAFE; 3,
Expand Down
8 changes: 4 additions & 4 deletions crates/compiler/gen_dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1491,16 +1491,16 @@ trait Backend<'a> {
arg_layouts,
ret_layout,
),
LowLevel::StrTrimLeft => self.build_fn_call(
LowLevel::StrTrimStart => self.build_fn_call(
sym,
bitcode::STR_TRIM_LEFT.to_string(),
bitcode::STR_TRIM_START.to_string(),
args,
arg_layouts,
ret_layout,
),
LowLevel::StrTrimRight => self.build_fn_call(
LowLevel::StrTrimEnd => self.build_fn_call(
sym,
bitcode::STR_TRIM_RIGHT.to_string(),
bitcode::STR_TRIM_END.to_string(),
args,
arg_layouts,
ret_layout,
Expand Down
8 changes: 4 additions & 4 deletions crates/compiler/gen_llvm/src/llvm/lowlevel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ pub(crate) fn run_low_level<'a, 'ctx>(

call_str_bitcode_fn(env, &[string], &[], BitcodeReturns::Str, bitcode::STR_TRIM)
}
StrTrimLeft => {
StrTrimStart => {
// Str.trim : Str -> Str
arguments!(string);

Expand All @@ -626,10 +626,10 @@ pub(crate) fn run_low_level<'a, 'ctx>(
&[string],
&[],
BitcodeReturns::Str,
bitcode::STR_TRIM_LEFT,
bitcode::STR_TRIM_START,
)
}
StrTrimRight => {
StrTrimEnd => {
// Str.trim : Str -> Str
arguments!(string);

Expand All @@ -638,7 +638,7 @@ pub(crate) fn run_low_level<'a, 'ctx>(
&[string],
&[],
BitcodeReturns::Str,
bitcode::STR_TRIM_RIGHT,
bitcode::STR_TRIM_END,
)
}
StrWithCapacity => {
Expand Down
4 changes: 2 additions & 2 deletions crates/compiler/gen_wasm/src/low_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ impl<'a> LowLevelCall<'a> {
backend.code_builder.i32_const(UPDATE_MODE_IMMUTABLE);
backend.call_host_fn_after_loading_args(bitcode::STR_FROM_UTF8_RANGE, 6, false);
}
StrTrimLeft => self.load_args_and_call_zig(backend, bitcode::STR_TRIM_LEFT),
StrTrimRight => self.load_args_and_call_zig(backend, bitcode::STR_TRIM_RIGHT),
StrTrimStart => self.load_args_and_call_zig(backend, bitcode::STR_TRIM_START),
StrTrimEnd => self.load_args_and_call_zig(backend, bitcode::STR_TRIM_END),
StrToUtf8 => self.load_args_and_call_zig(backend, bitcode::STR_TO_UTF8),
StrReserve => self.load_args_and_call_zig(backend, bitcode::STR_RESERVE),
StrReleaseExcessCapacity => {
Expand Down
8 changes: 4 additions & 4 deletions crates/compiler/module/src/low_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pub enum LowLevel {
StrRepeat,
StrFromFloat,
StrTrim,
StrTrimLeft,
StrTrimRight,
StrTrimStart,
StrTrimEnd,
StrToNum,
StrToScalars,
StrGetUnsafe,
Expand Down Expand Up @@ -260,8 +260,8 @@ map_symbol_to_lowlevel! {
StrToUtf8 <= STR_TO_UTF8,
StrRepeat <= STR_REPEAT,
StrTrim <= STR_TRIM,
StrTrimLeft <= STR_TRIM_LEFT,
StrTrimRight <= STR_TRIM_RIGHT,
StrTrimStart <= STR_TRIM_START,
StrTrimEnd <= STR_TRIM_END,
StrToScalars <= STR_TO_SCALARS,
StrGetUnsafe <= STR_GET_UNSAFE,
StrSubstringUnsafe <= STR_SUBSTRING_UNSAFE,
Expand Down
4 changes: 2 additions & 2 deletions crates/compiler/module/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1303,8 +1303,8 @@ define_builtins! {
15 STR_FROM_UTF8_RANGE: "fromUtf8Range"
16 STR_REPEAT: "repeat"
17 STR_TRIM: "trim"
18 STR_TRIM_LEFT: "trimLeft"
19 STR_TRIM_RIGHT: "trimRight"
18 STR_TRIM_START: "trimStart"
19 STR_TRIM_END: "trimEnd"
20 STR_TO_DEC: "toDec"
21 STR_TO_F64: "toF64"
22 STR_TO_F32: "toF32"
Expand Down
4 changes: 2 additions & 2 deletions crates/compiler/mono/src/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,8 @@ pub fn lowlevel_borrow_signature(arena: &Bump, op: LowLevel) -> &[Ownership] {
StrAppendScalar => arena.alloc_slice_copy(&[owned, irrelevant]),
StrGetScalarUnsafe => arena.alloc_slice_copy(&[borrowed, irrelevant]),
StrTrim => arena.alloc_slice_copy(&[owned]),
StrTrimLeft => arena.alloc_slice_copy(&[owned]),
StrTrimRight => arena.alloc_slice_copy(&[owned]),
StrTrimStart => arena.alloc_slice_copy(&[owned]),
StrTrimEnd => arena.alloc_slice_copy(&[owned]),
StrSplit => arena.alloc_slice_copy(&[borrowed, borrowed]),
StrToNum => arena.alloc_slice_copy(&[borrowed]),
ListPrepend => arena.alloc_slice_copy(&[owned, owned]),
Expand Down
4 changes: 2 additions & 2 deletions crates/compiler/mono/src/drop_specialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1583,8 +1583,8 @@ fn low_level_no_rc(lowlevel: &LowLevel) -> RC {
StrAppendScalar => RC::Rc,
StrGetScalarUnsafe => RC::NoRc,
StrTrim => RC::Rc,
StrTrimLeft => RC::Rc,
StrTrimRight => RC::Rc,
StrTrimStart => RC::Rc,
StrTrimEnd => RC::Rc,
StrSplit => RC::NoRc,
StrToNum => RC::NoRc,
ListPrepend => RC::Rc,
Expand Down
4 changes: 2 additions & 2 deletions crates/compiler/solve/tests/solve_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3797,11 +3797,11 @@ mod solve_expr {
}

#[test]
fn str_trim_left() {
fn str_trim_start() {
infer_eq_without_problem(
indoc!(
r#"
Str.trimLeft
Str.trimStart
"#
),
"Str -> Str",
Expand Down
Loading

0 comments on commit 97fa675

Please sign in to comment.