-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Rust] encoding primitive arrays now supports slice instead of array …
…(issue #1021) (#1040) * [Rust] codegen now implements: "From<&'a mut WriteBuf<'a>> for &'a mut [u8]" * [Rust] refactored codegen of primitive array encoding to accept slice instead of array * [Rust] updated some tests * [Rust] updated codegen to create additional function for primitive arrays that will accept an "impl Iterator". This allows an arbitrary number of items to be passed in, which will guarantee the correct number of items are encoded (defined 'nullValue' will be used where appropriate) * [Rust] generate at_most_*_items_from_slice setter for fixed sized primitive array in message * [Rust] add padded support for slice setter for primitive array field * [Rust] simplify impl of generated slice aware methods * merging in PR * [Rust] updated generator to create "_from_iter" and "_zero_padded" functions for primitive array * [Rust] updated generator to create "_from_iter" and "_zero_padded" functions for primitive array * fixed formatting issues * removed unused format argument --------- Co-authored-by: Michael Ward <[email protected]> Co-authored-by: Elvis Wang <[email protected]>
- Loading branch information
1 parent
34f2c32
commit a1bc244
Showing
10 changed files
with
1,369 additions
and
75 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,21 +1,22 @@ | ||
use BoostType::{NullVal, KERS, NITROUS, SUPERCHARGER, TURBO}; | ||
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>()?, TURBO, "Parse \"TURBO\" as BoostType"); | ||
assert_eq!("SUPERCHARGER".parse::<BoostType>()?, SUPERCHARGER, "Parse \"SUPERCHARGER\" as BoostType"); | ||
assert_eq!("NITROUS".parse::<BoostType>()?, NITROUS, "Parse \"NITROUS\" as BoostType"); | ||
assert_eq!("KERS".parse::<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!("Turbo".parse::<BoostType>()?, NullVal, "Parse \"Turbo\" as BoostType"); | ||
assert_eq!("Supercharger".parse::<BoostType>()?, NullVal, "Parse \"Supercharger\" as BoostType"); | ||
assert_eq!("Nitrous".parse::<BoostType>()?, NullVal, "Parse \"Nitrous\" as BoostType"); | ||
assert_eq!("Kers".parse::<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"); | ||
assert_eq!("AA".parse::<BoostType>()?, NullVal, "Parse \"AA\" as BoostType"); | ||
assert_eq!("".parse::<BoostType>().unwrap(), NullVal, "Parse \"\" as BoostType"); | ||
|
||
Ok(()) | ||
} |
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
Oops, something went wrong.