Skip to content

Commit 70d0624

Browse files
authored
Release v1.10.0 (#177)
Rev to v1.10.0 and update readme.
1 parent 8eed569 commit 70d0624

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

Readme.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,42 @@ public static async Task<HttpResponse> CreateUserAsync(
340340
}
341341
```
342342

343+
## Unwrapping
344+
345+
To bypass exhaustive matching and access a variant directly, use the variant-specific `Unwrap` methods.
346+
347+
This can be useful if you're sure of the underlying value or if you don't care about a potential exception at runtime.
348+
349+
```cs
350+
using Dunet;
351+
352+
[Union]
353+
partial record Option<T>
354+
{
355+
partial record Some(T Value);
356+
partial record None;
357+
}
358+
```
359+
360+
```cs
361+
Option<double> option1 = new Option<double>.Some(3.14);
362+
var some = option.UnwrapSome();
363+
// You can access `Value` directly here.
364+
Console.WriteLine(some.Value); // Prints "3.14".
365+
366+
Option<double> option2 = new Option<double>.None();
367+
// Throws `InvalidOperationException` because the underlying variant is `None`.
368+
var bad = option.UnwrapSome();
369+
```
370+
371+
> **Note**:
372+
> Unwrapping is unsafe. Use only when runtime errors are ok.
373+
343374
## Stateful Matching
344375

345-
To reduce memory allocations, use the `Match` overload that accepts a generic state parameter as its first argument. This allows your match parameter lambdas to be `static` but still flow state through:
376+
To reduce memory allocations, use the `Match` overload that accepts a generic state parameter as its first argument.
377+
378+
This allows your match parameter lambdas to be `static` but still flow state through:
346379

347380
```cs
348381
using Dunet;

src/Dunet.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
<PackageReadmeFile>Readme.md</PackageReadmeFile>
1515
<RepositoryUrl>https://github.com/domn1995/dunet</RepositoryUrl>
1616
<PackageTags>source; generator; discriminated; union; functional; tagged;</PackageTags>
17-
<AssemblyVersion>1.9.0</AssemblyVersion>
18-
<FileVersion>1.9.0</FileVersion>
17+
<AssemblyVersion>1.10.0</AssemblyVersion>
18+
<FileVersion>1.10.0</FileVersion>
1919
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2020
<PackageReleaseNotes>https://github.com/domn1995/dunet/releases</PackageReleaseNotes>
2121
<RepositoryType>git</RepositoryType>
2222
<PackageIcon>favicon.png</PackageIcon>
2323
<SignAssembly>False</SignAssembly>
24-
<Version>1.9.0</Version>
24+
<Version>1.10.0</Version>
2525
<NeutralLanguage>en</NeutralLanguage>
2626
<DevelopmentDependency>true</DevelopmentDependency>
2727
<NoWarn>$(NoWarn);NU5128</NoWarn>

0 commit comments

Comments
 (0)