-
Notifications
You must be signed in to change notification settings - Fork 557
[Rust] Enhance enum supporting fromstr and display and into #1020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vyazelenko
merged 8 commits into
aeron-io:master
from
wbprime:enhance-enum-supporting-fromstr-and-display
Nov 13, 2024
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
20ac5cf
[Rust] impl FromStr for generated enum items
wbprime cc3c466
[Rust] impl Display for generate enum items
wbprime 98fe82b
[Rust] impl Into for generated enum items
wbprime 6b0e9ad
[Rust] reformat code according to checkstyle failure report
wbprime e6d47c9
[Rust] split code in generateEnum to adress CI checkstyle method too …
wbprime 2de5483
[Rust] reformat code according to checkstyle failure
wbprime f96ccc6
[Rust] fix CodeQL warning by removing unused argument
wbprime 3b63ba4
[Rust] fix CodeQL warning by removing unused argument
wbprime File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| use examples_baseline::{ | ||
| boost_type::BoostType, | ||
| }; | ||
|
|
||
| #[test] | ||
| fn test_boost_type_from_str() -> Result<(), ()> { | ||
| assert_eq!("TURBO".parse::<BoostType>()?, BoostType::TURBO, "Parse \"TURBO\" as BoostType"); | ||
| assert_eq!("SUPERCHARGER".parse::<BoostType>()?, BoostType::SUPERCHARGER, "Parse \"SUPERCHARGER\" as BoostType"); | ||
| assert_eq!("NITROUS".parse::<BoostType>()?, BoostType::NITROUS, "Parse \"NITROUS\" as BoostType"); | ||
| assert_eq!("KERS".parse::<BoostType>()?, BoostType::KERS, "Parse \"KERS\" as BoostType"); | ||
|
|
||
| assert_eq!("Turbo".parse::<BoostType>()?, BoostType::NullVal, "Parse \"Turbo\" as BoostType"); | ||
| assert_eq!("Supercharger".parse::<BoostType>()?, BoostType::NullVal, "Parse \"Supercharger\" as BoostType"); | ||
| assert_eq!("Nitrous".parse::<BoostType>()?, BoostType::NullVal, "Parse \"Nitrous\" as BoostType"); | ||
| assert_eq!("Kers".parse::<BoostType>()?, BoostType::NullVal, "Parse \"Kers\" as BoostType"); | ||
|
|
||
| assert_eq!("AA".parse::<BoostType>()?, BoostType::NullVal, "Parse \"AA\" as BoostType"); | ||
| assert_eq!("".parse::<BoostType>().unwrap(), BoostType::NullVal, "Parse \"\" as BoostType"); | ||
|
|
||
| Ok(()) | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| use examples_baseline::{ | ||
| boost_type::BoostType, | ||
| }; | ||
|
|
||
| #[test] | ||
| fn test_boost_type_from_str() -> Result<(), ()> { | ||
| assert_eq!(<BoostType as Into<u8>>::into(BoostType::TURBO), 84_u8, "BoostType::TURBO into value"); | ||
| assert_eq!(<BoostType as Into<u8>>::into(BoostType::SUPERCHARGER), 83_u8, "BoostType::SUPERCHARGER into value"); | ||
| assert_eq!(<BoostType as Into<u8>>::into(BoostType::NITROUS), 78_u8, "BoostType::NITROUS into value"); | ||
| assert_eq!(<BoostType as Into<u8>>::into(BoostType::KERS), 75_u8, "BoostType::KERS into value"); | ||
| assert_eq!(<BoostType as Into<u8>>::into(BoostType::NullVal), 0_u8, "BoostType::NullVal into value"); | ||
|
|
||
| Ok(()) | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| use examples_baseline::{ | ||
| boost_type::BoostType, | ||
| }; | ||
|
|
||
| #[test] | ||
| fn test_boost_type_from_str() -> Result<(), ()> { | ||
| assert_eq!(format!("{}", BoostType::TURBO), "TURBO", "Display \"TURBO\""); | ||
| assert_eq!(format!("{}", BoostType::SUPERCHARGER), "SUPERCHARGER", "Display \"SUPERCHARGER\""); | ||
| assert_eq!(format!("{}", BoostType::NITROUS), "NITROUS", "Display \"NITROUS\""); | ||
| assert_eq!(format!("{}", BoostType::KERS), "KERS", "Display \"KERS\""); | ||
| assert_eq!(format!("{}", BoostType::NullVal), "NullVal", "Display \"NullVal\""); | ||
|
|
||
| Ok(()) | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.