-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Shot count is now represented as an unsigned 32-bit, up from
16-bit
- Loading branch information
Showing
14 changed files
with
60 additions
and
60 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
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
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
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,19 +1,19 @@ | ||
use std::num::NonZeroU16; | ||
use std::num::NonZeroU32; | ||
|
||
use pyo3::{exceptions::PyValueError, PyAny, PyResult}; | ||
|
||
pub(crate) fn try_from_u16_to_non_zero_u16(int: u16) -> PyResult<NonZeroU16> { | ||
NonZeroU16::new(int).ok_or(PyValueError::new_err("value must be non-zero")) | ||
pub(crate) fn try_from_u32_to_non_zero_u32(int: u32) -> PyResult<NonZeroU32> { | ||
NonZeroU32::new(int).ok_or(PyValueError::new_err("value must be non-zero")) | ||
} | ||
pub(crate) fn non_zero_u16(obj: &PyAny) -> PyResult<NonZeroU16> { | ||
let value: u16 = obj.extract()?; | ||
try_from_u16_to_non_zero_u16(value) | ||
pub(crate) fn non_zero_u32(obj: &PyAny) -> PyResult<NonZeroU32> { | ||
let value: u32 = obj.extract()?; | ||
try_from_u32_to_non_zero_u32(value) | ||
} | ||
|
||
pub(crate) fn optional_non_zero_u16(obj: &PyAny) -> PyResult<Option<NonZeroU16>> { | ||
let value: Option<u16> = obj.extract()?; | ||
pub(crate) fn optional_non_zero_u32(obj: &PyAny) -> PyResult<Option<NonZeroU32>> { | ||
let value: Option<u32> = obj.extract()?; | ||
match value { | ||
None => Ok(None), | ||
Some(int) => Ok(Some(try_from_u16_to_non_zero_u16(int)?)), | ||
Some(int) => Ok(Some(try_from_u32_to_non_zero_u32(int)?)), | ||
} | ||
} |
Oops, something went wrong.