Reorganize states and enter actions with enum-map #48
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.
Following from #39 and as part of #21, we can rename some of the states to identify what the pod is doing/has done rather than naming them after the action message. We can also simplify the correspondence for enter actions by using enum-map rather than
HashMap
. WithEnumMap
, all enum values must have an associated map value which eliminates the need for checking if the key exists. Additionally,EnumMap
stores the mapping as an array which should be more performant than hashing.The enter actions were previously just associated functions, but they'll need to manipulate pod components (e.g. the signal light, brakes, and others), so they were changed to actual methods which mutably borrow. The enter actions cannot be tested yet as the actual state transition logic from #39 needs to be fixed while completing #21.
Changes
HashMap
for complete mapping of enter actions