Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
2A5F committed Feb 22, 2025
1 parent b5a8fe7 commit 684290d
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sera.Union
# Coplt.Union

[![.NET](https://github.com/coplt/Coplt.Union/actions/workflows/dotnet.yml/badge.svg)](https://github.com/coplt/Coplt.Union/actions/workflows/dotnet.yml)
![MIT](https://img.shields.io/github/license/coplt/Coplt.Union)
Expand All @@ -13,7 +13,7 @@ Generate Tagged Union using source generator

- All unmanaged types will overlap
- All classes will overlap
- Other types will be tiled
- Other types are sequential

## Example

Expand Down Expand Up @@ -303,6 +303,9 @@ public readonly partial struct Union1

#### How to use

You can use pattern matching or manually determine the Tag.
But remember C# **does not have enum exhaustion semantics**.

```cs
var u = Union1.MakeA(123);

Expand All @@ -314,6 +317,20 @@ if (u.IsA)
{
var a = u.A;
}

switch (u.Tag)
{
case Union1.Tags.A:
break;
...
}

switch (u.Tag)
{
case { IsA: true, A: var a }:
break;
...
}
```

---
Expand Down

0 comments on commit 684290d

Please sign in to comment.