aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gleam/string.gleam10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/gleam/string.gleam b/src/gleam/string.gleam
index 8f6b5cb..00d58ad 100644
--- a/src/gleam/string.gleam
+++ b/src/gleam/string.gleam
@@ -246,9 +246,13 @@ pub fn drop_left(from string: String, up_to num_graphemes: Int) -> String {
/// ```
///
pub fn drop_start(from string: String, up_to num_graphemes: Int) -> String {
- case num_graphemes < 0 {
- True -> string
- False -> slice(string, num_graphemes, length(string) - num_graphemes)
+ case num_graphemes > 0 {
+ False -> string
+ True ->
+ case pop_grapheme(string) {
+ Ok(#(_, string)) -> drop_start(string, num_graphemes - 1)
+ Error(Nil) -> string
+ }
}
}