serde_cast

Crates.ioserde_cast
lib.rsserde_cast
version1.0.1
sourcesrc
created_at2023-11-09 14:27:12.07721
updated_at2023-11-09 14:30:15.965282
descriptionSimple A to B cast
homepagehttps://github.com/5GameMaker/serde_cast
repositoryhttps://github.com/5GameMaker/serde_cast
max_upload_size
id1030196
size5,600
Buj (5GameMaker)

documentation

https://docs.rs/bencher/

README

serde_cast

Works nicely with you_can!

  1. Have structs A and B
  2. Make sure they derive Serialize and Deserialize respectively
  3. Cast!
use serde::{Serialize, Deserialize};
use serde_cast::serde_cast;

#[derive(Serialize)]
struct A {
    field: String,
}

#[derive(Deserialize)]
struct B {
    field: String,
}

let a = A { field: "This was a mistake".to_string() };
let b: B = serde_cast!(&a);

assert_eq!(a.field, b.field);
Commit count: 5

cargo fmt