Skip to content

Commit

Permalink
fix: Serde example in
Browse files Browse the repository at this point in the history
Co-authored-by: SzczurekYT <67533827+szczurekyt@users.noreply.github.com>
  • Loading branch information
Norbiros and SzczurekYT committed Sep 1, 2024
1 parent eb27edc commit 1071358
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ fn example(bytes: &mut Bytes) {
## Serde
*Requires `serde` feature.*

```ignore
use crab_nbt::serde::arrays::IntArray;
```rust
use crab_nbt::serde::{arrays::IntArray, ser::to_bytes_unnamed, de::from_bytes_unnamed};
use serde::{Deserialize, Serialize};

#[derive(Deserialize, PartialEq, Debug)]
#[derive(Serialize, Deserialize, PartialEq, Debug)]
struct Test {
number: i32,
#[serde(with = "IntArray")]
Expand All @@ -85,9 +85,9 @@ fn cycle() {
number: 5,
int_array: vec![7, 8]
};
let bytes = to_bytes_unnamed(&test).unwrap();
let recreated_struct: Test = from_bytes_unnamed(&mut expected).unwrap();
let mut bytes = to_bytes_unnamed(&test).unwrap();
let recreated_struct: Test = from_bytes_unnamed(&mut bytes).unwrap();

assert_eq!(test, recreated_struct);
}
```
```

0 comments on commit 1071358

Please sign in to comment.