Crates.io | elm_rusty |
lib.rs | elm_rusty |
version | 0.1.0 |
source | src |
created_at | 2019-09-10 09:19:46.618052 |
updated_at | 2019-09-10 09:19:46.618052 |
description | Auto generate Rust models to Elm models |
homepage | |
repository | https://github.com/AbrarNitk/rust_elm_types |
max_upload_size | |
id | 163771 |
size | 16,721 |
#[macro_use]
extern crate elm_rusty;
// Declare struct with Elm derive
// Here path is mandatory in elm opts or export in env variable as ELM_TYPES
#[derive(Elm)]
#[elm(opts(path = "/Users/abrarkhan/Documents/github/rust_elm_types"))]
struct Foo {
id: i32,
name: String,
}
After change into models, When ever run cargo build, check or test first time it will generated corresponding Elm code.
module Foo exposing (..)
type alias Foo =
{ id: Int
, name: String
}
#[macro_use]
extern crate elm_rusty;
mod temp {
pub struct User {}
}
#[derive(Elm)]
#[elm(opts(rename = "ElmUser", path = "/Users/abrarkhan/Documents/github/rust_elm_types"))]
struct User {
name: Option<Vec<i32>>,
id: Vec<std::collections::HashMap<String, Vec<temp::User>>>,
vector: Vec<i32>,
}
module ElmUser exposing (..)
type alias ElmUser =
{ vector: List Int
, name: Maybe(List Int)
, id: List(Dict String(List User))
}
Here, I did not handle recursively custom type derive Elm, so it won't create corresponding User.elm
#[macro_use]
extern crate elm_rusty;
mod temp {
pub struct User {}
}
#[derive(Elm)]
#[elm(opts(rename = "ElmUser", path = "/Users/abrarkhan/Documents/github/rust_elm_types"))]
struct User {
#[elm(rename = "foo")]
name: Option<Vec<i32>>,
id: Vec<std::collections::HashMap<String, Vec<temp::User>>>,
vector: Vec<i32>,
}
module ElmUser exposing (..)
type alias ElmUser =
{ id: List(Dict String(List User))
, foo: Maybe(List Int)
, vector: List Int
}
#[macro_use]
extern crate elm_rusty;
mod temp {
pub struct User {}
}
#[derive(Elm)]
#[elm(opts(rename = "ElmUser", path = "/Users/abrarkhan/Documents/github/rust_elm_types"))]
struct User<'a> {
#[elm(rename = "foo")]
name: Option<Vec<i32>>,
id: &'a Vec<std::collections::HashMap<String, Vec<temp::User>>>,
vector: Vec<i32>,
}
module ElmUser exposing (..)
type alias ElmUser =
{ id: List(Dict String(List User))
, foo: Maybe(List Int)
, vector: List Int
}
#[macro_use]
extern crate elm_rusty;
mod temp {
pub struct User {}
}
#[derive(Elm)]
struct User<'a> {
#[elm(rename = "foo")]
name: Option<Vec<i32>>,
id: &'a Vec<std::collections::HashMap<String, Vec<temp::User>>>,
vector: Vec<i32>,
}
module User exposing (..)
type alias User =
{ id: List(Dict String(List User))
, foo: Maybe(List Int)
, vector: List Int
}