aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Łępicki <michal.lepicki@gmail.com>2020-12-05 11:14:46 +0100
committerLouis Pilfold <louis@lpil.uk>2020-12-06 10:24:29 +0000
commit78c90457dad39639dc384c046846d899c15f7cef (patch)
tree0bb37f12f7a78dc81fa3e2801fff75a563011766
parent46baf56bcf24cfbfae141b8bd1ad67417432e126 (diff)
downloadgleam_stdlib-78c90457dad39639dc384c046846d899c15f7cef.tar.gz
gleam_stdlib-78c90457dad39639dc384c046846d899c15f7cef.zip
Add bit_builder.from_string_builder
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/gleam/bit_builder.gleam8
2 files changed, 9 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 77a383a..62ab9b8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
- The `float` module gains the `sum` and `product` functions.
- The `result` module gains the `lazy_or` and `lazy_unwrap` functions.
- The `bool` module gains the `nand`, `nor`, `exclusive_nor`, and `exclusive_or` functions.
+- The `bit_builder` module gains the `from_string_builder` function.
## v0.12.0 - 2020-11-04
diff --git a/src/gleam/bit_builder.gleam b/src/gleam/bit_builder.gleam
index 165099f..12b3448 100644
--- a/src/gleam/bit_builder.gleam
+++ b/src/gleam/bit_builder.gleam
@@ -1,4 +1,5 @@
import gleam/bit_string.{BitString}
+import gleam/string_builder.{StringBuilder}
/// BitBuilder is a type used for efficiently concatenating bits to create bit
/// strings.
@@ -73,6 +74,13 @@ pub external fn concat(List(BitBuilder)) -> BitBuilder =
pub external fn from_string(String) -> BitBuilder =
"gleam_stdlib" "wrap_list"
+/// Create a new builder from a string builder.
+///
+/// Runs in constant time.
+///
+pub external fn from_string_builder(StringBuilder) -> BitBuilder =
+ "gleam_stdlib" "identity"
+
/// Create a new builder from a bit string.
///
/// Runs in constant time.