From 2633f0b6183e03da841e7e737a264f6b77b7c385 Mon Sep 17 00:00:00 2001 From: Oscar Bailey Date: Wed, 6 Apr 2022 09:22:55 +0100 Subject: [PATCH 1/2] Add more examples to README --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/README.md b/README.md index ed62511..4bf80e4 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,41 @@ if err != nil { } // fmt.Print(buf.Bytes()) ``` + +### Optional Types + +``` +type Person struct { + Name string + Age uint8 `bin:"optional"` +} +``` + +Rust equivalent: +``` +struct Person { + name: String, + age: Option +} +``` + +### Enum Types + +``` +type MyEnum struct { + Enum bin.BorshEnum `borsh_enum:"true"` + One bin.EmptyVariant + Two uint32 + Three int16 +} +``` + +Rust equivalent: +``` +enum MyEnum { + One, + Two(u32), + Three(i16), +} +``` + From 8ee5f1fbf541b1a1e08093feefd18e87d100da87 Mon Sep 17 00:00:00 2001 From: Oscar Bailey Date: Wed, 6 Apr 2022 09:23:46 +0100 Subject: [PATCH 2/2] Add syntax highlighting to new README examples --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4bf80e4..77d0dd7 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ if err != nil { ### Optional Types -``` +```golang type Person struct { Name string Age uint8 `bin:"optional"` @@ -36,7 +36,7 @@ type Person struct { ``` Rust equivalent: -``` +```rust struct Person { name: String, age: Option @@ -45,7 +45,7 @@ struct Person { ### Enum Types -``` +```golang type MyEnum struct { Enum bin.BorshEnum `borsh_enum:"true"` One bin.EmptyVariant @@ -55,7 +55,7 @@ type MyEnum struct { ``` Rust equivalent: -``` +```rust enum MyEnum { One, Two(u32),