struct2vec

Crates.iostruct2vec
lib.rsstruct2vec
version0.1.4
sourcesrc
created_at2021-08-21 15:36:46.123622
updated_at2022-05-25 13:29:05.495736
descriptionRust structure to slice.
homepagehttps://github.com/ptechen
repositoryhttps://github.com/ptechen/ToVec.git
max_upload_size
id440353
size2,755
Petechen (ptechen)

documentation

https://github.com/ptechen/ToVec/blob/main/README.md

README

ToVec

Rust structure to slice.

example one:

use struct2vec::ToVec;
use struct2vec_derive::ToVec;
use std::collections::HashMap;
#[derive(ToVec, Debug, Clone, Deserialize, Serialize)]
struct Custom {
    #[to_vec(comment = "用户名", field_type = "字段类型")]
    name: String,
}

let custom = Custom{name:String::from("123")};
custom.to_vec()

example two:

use struct2vec::ToVec;
use struct2vec_derive::ToVec;
use std::collections::HashMap;
use from_value_derive::From;
#[derive(ToVec, Debug, Clone, Deserialize, Serialize)]
struct Custom {
    #[to_vec(comment = "用户名", field_type = "字段类型")]
    name: String,
    data: Data
}

#[derive(From, Debug, Clone, Deserialize, Serialize)]
struct Data {
    key: String
}

let custom = Custom{name:String::from("123")};
custom.to_vec()
Commit count: 29

cargo fmt