]> git.mikk.net Git - mtbl-rs/commit
Generic sources working after big refactor.
authorChris Mikkelson <cmikk@fsi.io>
Tue, 23 Jul 2024 20:15:21 +0000 (15:15 -0500)
committerChris Mikkelson <cmikk@fsi.io>
Tue, 23 Jul 2024 20:21:20 +0000 (15:21 -0500)
commit4954779c07519da03e79ef588d029452623e72d6
tree90382ecdb983c577d009a2d4e52a5f30b512b0c5
parent0100af18fb33271a758d5a351f549aa393cf6dec
Generic sources working after big refactor.

Root cause was Box<dyn Trait> defaults to Box<dyn Trait + 'static>,
leading to the 'static lifetime "infecting" the generated iterators,
causing the borrow to last beyond the end of the function which dropped
the box or its containing structure.

The quick fix was to inject and add an explicit lifetime to the Box.

While tuning that fix, opted to inject lifetimes by implementing
Source methods on references. This tracks more with the C mtbl API,
where:

m = mtbl_merger_init(mopt);
/* populate m */
mtbl_merger_source(m);

is roughly mirrored by:

let m = mtbl::Merger::from(...);
let source = &m;
src/lib.rs
src/merger.rs
src/source.rs