Skip to content

Commit

Permalink
use fn
Browse files Browse the repository at this point in the history
  • Loading branch information
rsk0315 committed Feb 13, 2024
1 parent ee2b755 commit 2cb4ed9
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions nekolib-src/ds/rs01_dict/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::ops::Range;
use std::ops::{Range, RangeInclusive};

Check failure on line 1 in nekolib-src/ds/rs01_dict/src/lib.rs

View workflow job for this annotation

GitHub Actions / push-to-gh-pages

unused import: `Range`

fn compress_vec_bool<const W: usize>(buf: &[bool]) -> Vec<u64> {

Check failure on line 3 in nekolib-src/ds/rs01_dict/src/lib.rs

View workflow job for this annotation

GitHub Actions / push-to-gh-pages

function `compress_vec_bool` is never used
let n = buf.len();
Expand All @@ -16,8 +16,13 @@ const LG_N: usize = 8;

const LARGE: usize = LG_N * LG_N;

Check failure on line 17 in nekolib-src/ds/rs01_dict/src/lib.rs

View workflow job for this annotation

GitHub Actions / push-to-gh-pages

constant `LARGE` is never used
const SMALL: usize = LG_N / 2;

Check failure on line 18 in nekolib-src/ds/rs01_dict/src/lib.rs

View workflow job for this annotation

GitHub Actions / push-to-gh-pages

constant `SMALL` is never used
const RANK_LOOKUP: [[u16; SMALL]; 1 << SMALL] = {
let mut table = [[0; SMALL]; 1 << SMALL];
const POW2_SMALL: usize = 1 << SMALL;

Check failure on line 19 in nekolib-src/ds/rs01_dict/src/lib.rs

View workflow job for this annotation

GitHub Actions / push-to-gh-pages

constant `POW2_SMALL` is never used
const RANK_LOOKUP: [[u16; SMALL]; POW2_SMALL] =

Check failure on line 20 in nekolib-src/ds/rs01_dict/src/lib.rs

View workflow job for this annotation

GitHub Actions / push-to-gh-pages

constant `RANK_LOOKUP` is never used
rank_lookup::<SMALL, POW2_SMALL>();

const fn rank_lookup<const SMALL: usize, const POW2_SMALL: usize>()

Check failure on line 23 in nekolib-src/ds/rs01_dict/src/lib.rs

View workflow job for this annotation

GitHub Actions / push-to-gh-pages

function `rank_lookup` is never used
-> [[u16; SMALL]; POW2_SMALL] {
let mut table = [[0; SMALL]; POW2_SMALL];
let mut i = 0;
while i < (1 << SMALL) {
table[i][0] = (i & 1) as u16;
Expand All @@ -29,7 +34,7 @@ const RANK_LOOKUP: [[u16; SMALL]; 1 << SMALL] = {
i += 1;
}
table
};
}

struct RankPreprocess<const LARGE: usize, const SMALL: usize> {

Check failure on line 39 in nekolib-src/ds/rs01_dict/src/lib.rs

View workflow job for this annotation

GitHub Actions / push-to-gh-pages

struct `RankPreprocess` is never constructed
buf: Vec<u64>,
Expand Down Expand Up @@ -128,15 +133,17 @@ macro_rules! bitvec {
}

#[test]
fn rank_lookup() {
assert_eq!(&RANK_LOOKUP[0b000][0..3], [0, 0, 0]);
assert_eq!(&RANK_LOOKUP[0b100][0..3], [0, 0, 1]);
assert_eq!(&RANK_LOOKUP[0b010][0..3], [0, 1, 1]);
assert_eq!(&RANK_LOOKUP[0b110][0..3], [0, 1, 2]);
assert_eq!(&RANK_LOOKUP[0b001][0..3], [1, 1, 1]);
assert_eq!(&RANK_LOOKUP[0b101][0..3], [1, 1, 2]);
assert_eq!(&RANK_LOOKUP[0b011][0..3], [1, 2, 2]);
assert_eq!(&RANK_LOOKUP[0b111][0..3], [1, 2, 3]);
fn test_rank_lookup() {
let table = rank_lookup::<3, 8>();

assert_eq!(&table[0b000][0..3], [0, 0, 0]);
assert_eq!(&table[0b100][0..3], [0, 0, 1]);
assert_eq!(&table[0b010][0..3], [0, 1, 1]);
assert_eq!(&table[0b110][0..3], [0, 1, 2]);
assert_eq!(&table[0b001][0..3], [1, 1, 1]);
assert_eq!(&table[0b101][0..3], [1, 1, 2]);
assert_eq!(&table[0b011][0..3], [1, 2, 2]);
assert_eq!(&table[0b111][0..3], [1, 2, 3]);
}

#[test]
Expand Down

0 comments on commit 2cb4ed9

Please sign in to comment.