diff options
author | Erik Terpstra <39518+eterps@users.noreply.github.com> | 2020-05-11 16:31:36 +0200 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2020-05-12 11:05:04 +0100 |
commit | 5ac301a947a3d6618f00db88f84bb932d75e1a8f (patch) | |
tree | aeb9a50e458915a5d27ab2393783be28891705bd /src | |
parent | 8069fabc19c23197d551d0f969a135840d86d808 (diff) | |
download | gleam_stdlib-5ac301a947a3d6618f00db88f84bb932d75e1a8f.tar.gz gleam_stdlib-5ac301a947a3d6618f00db88f84bb932d75e1a8f.zip |
string.trim
Diffstat (limited to 'src')
-rw-r--r-- | src/gleam/string.gleam | 6 | ||||
-rw-r--r-- | src/gleam_stdlib.erl | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/gleam/string.gleam b/src/gleam/string.gleam index 8c270bc..bde93e2 100644 --- a/src/gleam/string.gleam +++ b/src/gleam/string.gleam @@ -309,7 +309,7 @@ pub fn join(strings: List(String), with separator: String) -> String { // // // pub fn pad_right(string: String, to size: Int, with: String) {} -// TODO + // Get rid of whitespace on both sides of a String. // // ## Examples @@ -317,7 +317,9 @@ pub fn join(strings: List(String), with separator: String) -> String { // "hats" // // -// pub fn trim(string: String) -> String {} +pub external fn trim(String) -> String = + "gleam_stdlib" "string_trim" + // TODO // Get rid of whitespace on the left of a String. // diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl index 49a7e2a..54fcdaa 100644 --- a/src/gleam_stdlib.erl +++ b/src/gleam_stdlib.erl @@ -7,7 +7,7 @@ iodata_append/2, iodata_prepend/2, identity/1, decode_int/1, decode_string/1, decode_bool/1, decode_float/1, decode_thunk/1, decode_atom/1, decode_list/1, decode_field/2, decode_element/2, parse_int/1, parse_float/1, compare_strings/2, - string_contains/2]). + string_contains/2, string_trim/1]). should_equal(Actual, Expected) -> ?assertEqual(Expected, Actual). should_not_equal(Actual, Expected) -> ?assertNotEqual(Expected, Actual). @@ -127,3 +127,5 @@ string_contains(Haystack, Needle) -> _ -> true end. + +string_trim(String) -> string:trim(String, both). |