-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
impl(generator): Rust uses strings for enum values (#88)
We decided to use strings for enum values, as the transport will be HTTP + JSON. The generator creates some helper constants in a properly named module, that prevents typos.
- Loading branch information
Showing
4 changed files
with
30 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
|
||
{{#DocLines}} | ||
/// {{{.}}} | ||
{{/DocLines}} | ||
#[derive(Clone, Debug, Default, Deserialize, Serialize)] | ||
pub struct {{Name}}(i32); | ||
pub struct {{Name}}(String); | ||
|
||
impl {{Name}} { | ||
/// Useful constants to work with [{{Name}}]({{Name}}) | ||
pub mod {{NameSnakeCase}} { | ||
{{#Values}} | ||
|
||
{{#DocLines}} | ||
/// {{{.}}} | ||
{{/DocLines}} | ||
pub const {{Name}}: {{EnumType}} = {{EnumType}}({{Number}}); | ||
pub const {{Name}}: &str = "{{Name}}"; | ||
{{/Values}} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters