diff --git a/Cargo.toml b/Cargo.toml index d0e7949..09b4b99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["codegen", "tools/create-data-file", "tools/dump-data-file"] [package] name = "data_bucket" -version = "0.3.9" +version = "0.3.10" edition = "2021" authors = ["Handy-caT"] license = "MIT" diff --git a/src/util/sized.rs b/src/util/sized.rs index 61ad529..5278af0 100644 --- a/src/util/sized.rs +++ b/src/util/sized.rs @@ -176,6 +176,10 @@ impl SizeMeasurable for Option where T: SizeMeasurable, { + fn align() -> Option { + T::align() + } + fn aligned_size(&self) -> usize { size_of::>() } @@ -295,11 +299,24 @@ mod test { to_bytes::(&t).unwrap().len() ); let t = (u8::MAX, Link::default()); + assert_eq!( + t.aligned_size(), + to_bytes::(&t).unwrap().len() + ); + let t = (Some(0.0f64), Link::default()); assert_eq!( t.aligned_size(), to_bytes::(&t).unwrap().len() ) } + #[test] + fn test_option() { + let t = Some(0.0f64); + assert_eq!( + t.aligned_size(), + to_bytes::(&t).unwrap().len() + ); + } #[test] fn test_string() {