Merge pull request 'Const UBF' (#23) from const-ubf into main
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good

Reviewed-on: #23
This commit is contained in:
Robin Müller 2023-08-16 18:17:13 +02:00
commit fc7bee342c
3 changed files with 8 additions and 2 deletions

View File

@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
# [unreleased] # [unreleased]
## Changed
- `UnsignedByteField` and `GenericUnsignedByteField` `new` methods are `const` now.
# [v0.7.0-beta.0] 2023-08-16 # [v0.7.0-beta.0] 2023-08-16
- Moved MSRV from v1.60 to v1.61. - Moved MSRV from v1.60 to v1.61.

View File

@ -718,6 +718,8 @@ mod tests {
assert_eq!(default_conf.crc_flag, CrcFlag::NoCrc); assert_eq!(default_conf.crc_flag, CrcFlag::NoCrc);
assert_eq!(default_conf.file_flag, LargeFileFlag::Normal); assert_eq!(default_conf.file_flag, LargeFileFlag::Normal);
} }
#[test]
fn test_pdu_header_setter() { fn test_pdu_header_setter() {
let src_id = UnsignedByteFieldU8::new(1); let src_id = UnsignedByteFieldU8::new(1);
let dest_id = UnsignedByteFieldU8::new(2); let dest_id = UnsignedByteFieldU8::new(2);

View File

@ -123,7 +123,7 @@ pub struct UnsignedByteField {
} }
impl UnsignedByteField { impl UnsignedByteField {
pub fn new(width: usize, value: u64) -> Self { pub const fn new(width: usize, value: u64) -> Self {
Self { width, value } Self { width, value }
} }
@ -204,7 +204,7 @@ pub struct GenericUnsignedByteField<TYPE> {
} }
impl<TYPE> GenericUnsignedByteField<TYPE> { impl<TYPE> GenericUnsignedByteField<TYPE> {
pub fn new(val: TYPE) -> Self { pub const fn new(val: TYPE) -> Self {
Self { value: val } Self { value: val }
} }
} }