Skip to content

Commit

Permalink
Update to MSRV 1.74 (#149)
Browse files Browse the repository at this point in the history
* upd

* fix tuple_array_conversions
  • Loading branch information
kampersanda authored Feb 19, 2024
1 parent 3f7d16f commit 19991ae
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
rust:
- 1.70.0 # MSRV
- 1.74.0 # MSRV
- stable
- nightly
steps:
Expand Down
2 changes: 1 addition & 1 deletion vibrato/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>",
"Koichi Akabe <[email protected]>",
Expand Down
32 changes: 29 additions & 3 deletions vibrato/src/dictionary/connector/raw_connector/scorer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ impl Default for U31x8 {

impl Decode for U31x8 {
fn decode<D: Decoder>(decoder: &mut D) -> Result<Self, DecodeError> {
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);
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 19991ae

Please sign in to comment.