Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more examples to README.md #3

Merged
merged 2 commits into from Apr 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 38 additions & 0 deletions README.md
Expand Up @@ -25,3 +25,41 @@ if err != nil {
}
// fmt.Print(buf.Bytes())
```

### Optional Types

```golang
type Person struct {
Name string
Age uint8 `bin:"optional"`
}
```

Rust equivalent:
```rust
struct Person {
name: String,
age: Option<u8>
}
```

### Enum Types

```golang
type MyEnum struct {
Enum bin.BorshEnum `borsh_enum:"true"`
One bin.EmptyVariant
Two uint32
Three int16
}
```

Rust equivalent:
```rust
enum MyEnum {
One,
Two(u32),
Three(i16),
}
```