diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7a78450..696f12b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -23,7 +23,7 @@ jobs: strategy: matrix: rust: - - 1.70.0 # MSRV + - 1.74.0 # MSRV - stable - nightly steps: diff --git a/vibrato/Cargo.toml b/vibrato/Cargo.toml index 3cfa0ac..e55c158 100644 --- a/vibrato/Cargo.toml +++ b/vibrato/Cargo.toml @@ -3,7 +3,7 @@ name = "vibrato" # NOTE(kampersanda): Developers should check compatibility with MODEL_MAGIC in dictionary.rs. version = "0.5.1" edition = "2021" -rust-version = "1.70" +rust-version = "1.74" authors = [ "Shunsuke Kanda ", "Koichi Akabe ", diff --git a/vibrato/src/dictionary/connector/raw_connector/scorer.rs b/vibrato/src/dictionary/connector/raw_connector/scorer.rs index b8ef6f8..17646e8 100644 --- a/vibrato/src/dictionary/connector/raw_connector/scorer.rs +++ b/vibrato/src/dictionary/connector/raw_connector/scorer.rs @@ -60,9 +60,7 @@ impl Default for U31x8 { impl Decode for U31x8 { fn decode(decoder: &mut D) -> Result { - let (a, b, c, d, e, f, g, h): (U31, U31, U31, U31, U31, U31, U31, U31) = - Decode::decode(decoder)?; - let data = [a, b, c, d, e, f, g, h]; + let data: [U31; 8] = Decode::decode(decoder)?; // Safety debug_assert_eq!(std::mem::size_of_val(data.as_slice()), 32); @@ -480,4 +478,32 @@ mod tests { assert_eq!(scorer.accumulate_cost(&[], &[]), 0); } + + #[cfg(not(target_feature = "avx2"))] + #[test] + fn u31x8_encode_decode_test() { + let data = U31x8([ + U31::new(0).unwrap(), + U31::new(1).unwrap(), + U31::new(2).unwrap(), + U31::new(3).unwrap(), + U31::new(4).unwrap(), + U31::new(5).unwrap(), + U31::new(6).unwrap(), + U31::new(7).unwrap(), + ]); + + let slice: &mut [u8] = &mut [0; 32]; + let config = bincode::config::standard(); + + let mut encoder = + bincode::enc::EncoderImpl::new(bincode::enc::write::SliceWriter::new(slice), config); + data.encode(&mut encoder).unwrap(); + + let mut decoder = + bincode::de::DecoderImpl::new(bincode::de::read::SliceReader::new(slice), config); + let decoded = U31x8::decode(&mut decoder).unwrap(); + + assert_eq!(data.0, decoded.0); + } }