From: Kostya Shishkov Date: Sat, 9 Nov 2024 17:15:47 +0000 (+0100) Subject: core/codebook: make TableCodebookDescReader accept closures as well X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=fe18d1c88c8806aea8ba0fb1797b7e55b91efd7d;p=nihav.git core/codebook: make TableCodebookDescReader accept closures as well --- diff --git a/nihav-core/src/io/codebook.rs b/nihav-core/src/io/codebook.rs index 625009f..97a6a8d 100644 --- a/nihav-core/src/io/codebook.rs +++ b/nihav-core/src/io/codebook.rs @@ -423,13 +423,13 @@ impl<'a> CodebookDescReader for ShortCodebookDescReader<'a> { pub struct TableCodebookDescReader<'a, CodeType:'static, IndexType:'static> { bits: &'a [u8], codes: &'a [CodeType], - idx_map: fn(usize) -> IndexType, + idx_map: Box IndexType>, } impl<'a, CodeType, IndexType> TableCodebookDescReader<'a, CodeType, IndexType> { /// Constructs a new `TableCodebookDescReader` instance. - pub fn new(codes: &'a [CodeType], bits: &'a [u8], idx_map: fn(usize) -> IndexType) -> Self { - Self { bits, codes, idx_map } + pub fn new IndexType + 'static>(codes: &'a [CodeType], bits: &'a [u8], map_func: MapFunc) -> Self { + Self { bits, codes, idx_map: Box::new(map_func) } } } impl<'a, CodeType: Copy+Into, IndexType> CodebookDescReader for TableCodebookDescReader<'a, CodeType, IndexType>