Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use serde::Serialize;
- #[derive(Serialize)]
- struct Struct {
- a: String,
- b: String,
- #[serde(skip_serializing)]
- c: String // marked for no serialization via serde
- }
- #[derive(Serialize)]
- struct HandlebarsStruct<'a> {
- a: &'a String,
- b: &'a String,
- c: &'a String,
- }
- impl Struct {
- fn as_handlebars_view<'a>(&'a self) -> HandlebarsStruct<'a> {
- HandlebarsStruct {
- a: &self.a,
- b: &self.b,
- c: &self.c
- }
- }
- }
- fn main() {
- let s = Struct {
- a: "a".to_string(),
- b: "b".to_string(),
- c: "c".to_string()
- };
- let _hb_struct = s.as_handlebars_view();
- // do handlebars stuff with hb_struct
- }
Add Comment
Please, Sign In to add comment