diff --git a/CHANGELOG.md b/CHANGELOG.md index 1aa9b48..86b3466 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +## [3.0.1] - 2024-12-16 + +- Added one inverse example for `none_in`. + ## [3.0.0] - 2024-12-16 - Updated labels and internal code to be more consistent. - +git ## [2.0.0] - 2024-12-14 - Removed `given` function prefixes from most functions to cut down import diff --git a/README.md b/README.md index 2262646..fa49b6c 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,33 @@ import given.{given, not_given} import gleam/io import gleam/option.{None, Some} +pub fn main() { + given_example() |> io.debug() + // "🤯 Woof!" + + not_given_example() |> io.debug() + // "👌 Access granted..." + + given_ok_in_example() |> io.debug() + // "Hello Joe!" + + given_error_in_example() |> io.debug() + // "Memory exhausted!" + + given_some_in_example() |> io.debug() + // "One Penny" + + given_none_in_example() |> io.debug() + // "Nothing at all" + + given_none_in_another_example() |> io.debug() + // "None here" +} + +import given.{given, not_given} +import gleam/io +import gleam/option.{None, Some} + pub fn main() { given_example() |> io.debug() // "🤯 Woof!" @@ -116,6 +143,15 @@ pub fn given_none_in_example() { "Nothing at all" } + +pub fn given_none_in_another_example() { + let an_option = None + use else_some_value <- given.none_in(an_option, return: fn() { "None here" }) + + // …handle Some value here… + + else_some_value +} ``` Further documentation can be found at . diff --git a/gleam.toml b/gleam.toml index 13ba17f..bb4e26c 100644 --- a/gleam.toml +++ b/gleam.toml @@ -1,5 +1,5 @@ name = "given" -version = "3.0.0" +version = "3.0.1" # Fill out these fields if you intend to generate HTML documentation or publish # your project to the Hex package manager. diff --git a/src/given/internal/examples.gleam b/src/given/internal/examples.gleam index 3175f94..a7263a7 100644 --- a/src/given/internal/examples.gleam +++ b/src/given/internal/examples.gleam @@ -79,3 +79,12 @@ pub fn given_none_in_example() { "Nothing at all" } + +pub fn given_none_in_another_example() { + let an_option = None + use else_some_value <- given.none_in(an_option, return: fn() { "None here" }) + + // …handle Some value here… + + else_some_value +} diff --git a/test/given_test.gleam b/test/given_test.gleam index 5560d37..0b9efc0 100644 --- a/test/given_test.gleam +++ b/test/given_test.gleam @@ -138,9 +138,11 @@ pub fn given_none_in_2nd_test() { { let option = None - use some_value <- given.none_in(option, return: fn() { "None encountered!" }) + use else_some_value <- given.none_in(option, return: fn() { + "None encountered!" + }) // …user handles Some value here… - some_value + else_some_value } |> should.equal("None encountered!") }