aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Thompson <andrew.thompson@qmul.ac.uk>2022-02-22 17:49:40 +0000
committerLouis Pilfold <louis@lpil.uk>2022-02-22 18:06:21 +0000
commit7288ed1415216c2e5060b92ffd667c15ca94c108 (patch)
treedfe52f9a7d65644f996630bb085e790c4e2e87df
parent959115c8cfd1231be8196598687771a1618bfa40 (diff)
downloadgleam_stdlib-7288ed1415216c2e5060b92ffd667c15ca94c108.tar.gz
gleam_stdlib-7288ed1415216c2e5060b92ffd667c15ca94c108.zip
:sparkles: Add `new` constructors for empty BitStrings and StringBuilers.
-rw-r--r--src/gleam/bit_builder.gleam7
-rw-r--r--src/gleam/string_builder.gleam7
2 files changed, 14 insertions, 0 deletions
diff --git a/src/gleam/bit_builder.gleam b/src/gleam/bit_builder.gleam
index 90f8866..14c197e 100644
--- a/src/gleam/bit_builder.gleam
+++ b/src/gleam/bit_builder.gleam
@@ -28,6 +28,13 @@ if javascript {
}
}
+/// Create an empty `BitBuilder`. Useful as the start of a pipe chaning many
+/// builders together.
+///
+pub fn new () -> BitBuilder {
+ do_concat([])
+}
+
/// Prepends a bit string to the start of a builder.
///
/// Runs in constant time.
diff --git a/src/gleam/string_builder.gleam b/src/gleam/string_builder.gleam
index dc3ad23..26b7697 100644
--- a/src/gleam/string_builder.gleam
+++ b/src/gleam/string_builder.gleam
@@ -14,6 +14,13 @@
///
pub external type StringBuilder
+/// Create an empty `StringBuilder`. Useful as the start of a pipe chaning many
+/// builders together.
+///
+pub fn new() -> StringBuilder {
+ do_from_strings([])
+}
+
/// Prepends a `String` onto the start of some `StringBuilder`.
///
/// Runs in constant time.