Implement the functionality for the NonZeroGpr type utilized in the GprOrZero enum within the /app/ directory. The NonZeroGpr type should represent general-purpose registers with values ranging from 1 to 31, inclusive.
Requirements:
New Structure: Create a new struct named NonZeroGpr that:
Holds a single u32 field to store the register number.
Ensures that this number must not be zero and must be within the range [1, 31].
Constructor: Implement a constructor method new(x: u32) -> Option<NonZeroGpr> that:
Returns None if x is 0 or outside the range [1, 31].
Returns Some(NonZeroGpr) if x is valid.
Method as_u32: Implement a method as_u32(&self) -> u32 that:
Returns the stored register number as a u32.
Debug and Display Traits: Implement the Debug and Display traits for NonZeroGpr to format the output:
The Display implementation should return the format "rX" where X is the register number.
The Debug implementation should mirror the Display format.
Safety: Ensure that the struct properly handles the constraints of being non-zero and within the valid range when created.
This implementation should fully complement the GprOrZero enum and make all the provided tests in the gpr_or_zero_tests test module pass. Place your code in the /app/ directory, ensuring the structure and interfaces align with the existing GprOrZero implementation.