Show More
@@ -47,15 +47,15 b' fn inset(bitset: &[u32; 8], c: u8) -> bo' | |||||
47 |
|
47 | |||
48 | const MAXENCODE: usize = 4096 * 4; |
|
48 | const MAXENCODE: usize = 4096 * 4; | |
49 |
|
49 | |||
50 | struct DestArr { |
|
50 | struct DestArr<const N: usize> { | |
51 |
buf: [u8; |
|
51 | buf: [u8; N], | |
52 | pub len: usize, |
|
52 | pub len: usize, | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | impl DestArr { |
|
55 | impl<const N: usize> DestArr<N> { | |
56 | pub fn create() -> Self { |
|
56 | pub fn create() -> Self { | |
57 | DestArr { |
|
57 | DestArr { | |
58 |
buf: [0; |
|
58 | buf: [0; N], | |
59 | len: 0, |
|
59 | len: 0, | |
60 | } |
|
60 | } | |
61 | } |
|
61 | } | |
@@ -65,7 +65,7 b' impl DestArr {' | |||||
65 | } |
|
65 | } | |
66 | } |
|
66 | } | |
67 |
|
67 | |||
68 | impl Sink for DestArr { |
|
68 | impl<const N: usize> Sink for DestArr<N> { | |
69 | fn write_byte(&mut self, c: u8) { |
|
69 | fn write_byte(&mut self, c: u8) { | |
70 | self.buf[self.len] = c; |
|
70 | self.buf[self.len] = c; | |
71 | self.len += 1; |
|
71 | self.len += 1; | |
@@ -600,9 +600,9 b' fn hash_mangle(src: &[u8], sha: &[u8]) -' | |||||
600 | } |
|
600 | } | |
601 |
|
601 | |||
602 | fn hash_encode(src: &[u8]) -> Vec<u8> { |
|
602 | fn hash_encode(src: &[u8]) -> Vec<u8> { | |
603 | let mut dired = DestArr::create(); |
|
603 | let mut dired: DestArr<MAXENCODE> = DestArr::create(); | |
604 | let mut lowered = DestArr::create(); |
|
604 | let mut lowered: DestArr<MAXENCODE> = DestArr::create(); | |
605 | let mut auxed = DestArr::create(); |
|
605 | let mut auxed: DestArr<MAXENCODE> = DestArr::create(); | |
606 | let baselen = (src.len() - 5) * 3; |
|
606 | let baselen = (src.len() - 5) * 3; | |
607 | if baselen >= MAXENCODE { |
|
607 | if baselen >= MAXENCODE { | |
608 | panic!("path_encode::hash_encore: string too long: {}", baselen) |
|
608 | panic!("path_encode::hash_encore: string too long: {}", baselen) |
General Comments 0
You need to be logged in to leave comments.
Login now