Skip to content

Commit

Permalink
Add tags to code blocks. Update gitignore.
Browse files Browse the repository at this point in the history
  • Loading branch information
kabergstrom committed Nov 9, 2019
1 parent 46ea92e commit aaf881f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/target
target
**/*.rs.bk
Cargo.lock
.idea
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ Works for most basic use-cases. Includes derive macro, some standard library typ

## Usage
On a struct:
```
```rust
#[derive(SerdeDiff, Serialize, Deserialize)]
```

Serialize & apply differences:

bincode
```
```rust
let bincode_data = bincode::serialize(&Diff::serializable(&old, &new)).unwrap();
bincode::config()
.deserialize_seed(Apply::deserializable(&mut target), &bincode_data)
.unwrap();
```
serde_json
```
```rust
let json_data = serde_json::to_string(&Diff::serializable(&old, &new)).unwrap();
let mut deserializer = serde_json::Deserializer::from_str(&json_data);
Apply::apply(&mut deserializer, &mut target).unwrap();
Expand All @@ -44,14 +44,14 @@ serde_json
# Simple example

`Cargo.toml`
```
```toml
[dependencies]
serde-diff = "0.1.1"
serde = "1"
serde_json = "1" // all serde formats are supported, serde_json is shown in this example
```
`main.rs`
```
```rust
use serde_diff::{Apply, Diff, SerdeDiff};
use serde::{Serialize, Deserialize};
#[derive(SerdeDiff, Serialize, Deserialize, Debug)]
Expand Down

0 comments on commit aaf881f

Please sign in to comment.