aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorErik Terpstra <39518+eterps@users.noreply.github.com>2020-05-12 13:01:25 +0200
committerLouis Pilfold <louis@lpil.uk>2020-05-12 22:30:45 +0100
commit190a7d667e4b99f8b3c11ef991ce1eb879aa5c9c (patch)
treea025d209f682ffb23c090409f853fa815a6355b7 /src
parenteb043ee431c3d5592610eeb5f12a0d91fb5c17a0 (diff)
downloadgleam_stdlib-190a7d667e4b99f8b3c11ef991ce1eb879aa5c9c.tar.gz
gleam_stdlib-190a7d667e4b99f8b3c11ef991ce1eb879aa5c9c.zip
string.trim_left & string.trim_right
Diffstat (limited to 'src')
-rw-r--r--src/gleam/string.gleam42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/gleam/string.gleam b/src/gleam/string.gleam
index 1dd484a..2cad6f2 100644
--- a/src/gleam/string.gleam
+++ b/src/gleam/string.gleam
@@ -311,6 +311,8 @@ pub fn join(strings: List(String), with separator: String) -> String {
// pub fn pad_right(string: String, to size: Int, with: String) {}
type Direction {
+ Leading
+ Trailing
Both
}
@@ -328,24 +330,28 @@ pub fn trim(string: String) -> String {
erl_trim(string, Both)
}
-// TODO
-// Get rid of whitespace on the left of a String.
-//
-// ## Examples
-// > trim_left(" hats \n")
-// "hats \n"
-//
-//
-// pub fn trim_left(string: String) -> String {}
-// TODO
-// Get rid of whitespace on the right of a String.
-//
-// ## Examples
-// > trim_right(" hats \n")
-// " hats"
-//
-//
-// pub fn trim_right(string: String) -> String {}
+/// Get rid of whitespace on the left of a String.
+///
+/// ## Examples
+/// > trim_left(" hats \n")
+/// "hats \n"
+///
+///
+pub fn trim_left(string: String) -> String {
+ erl_trim(string, Leading)
+}
+
+/// Get rid of whitespace on the right of a String.
+///
+/// ## Examples
+/// > trim_right(" hats \n")
+/// " hats"
+///
+///
+pub fn trim_right(string: String) -> String {
+ erl_trim(string, Trailing)
+}
+
// TODO
// /// Convert a string to a list of Graphemes.
// ///