From fe18d1c88c8806aea8ba0fb1797b7e55b91efd7d Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sat, 9 Nov 2024 18:15:47 +0100 Subject: [PATCH] core/codebook: make TableCodebookDescReader accept closures as well --- nihav-core/src/io/codebook.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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> -- 2.39.5