From 2832ffbe077230b89222479da8b737142c9efe1b Mon Sep 17 00:00:00 2001 From: tslil Date: Tue, 28 Oct 2025 20:14:27 +0000 Subject: Playing with macro_rules, sigh. --- rprt-engine/src/selection.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'rprt-engine/src/selection.rs') diff --git a/rprt-engine/src/selection.rs b/rprt-engine/src/selection.rs index 9e619a4..341c6ad 100644 --- a/rprt-engine/src/selection.rs +++ b/rprt-engine/src/selection.rs @@ -83,6 +83,15 @@ where SelectionError(SelectionError), } +impl From for VectoriseError +where + E: std::error::Error + 'static, +{ + fn from(err: E) -> Self { + VectoriseError::ProcessingError(err) + } +} + impl Selection { pub fn empty() -> Self { Self::MultiRanges { @@ -273,10 +282,10 @@ impl Selection { } pub fn vectorise( - fn_rank_zero: impl Fn(&S, BufferID, usize) -> Result, - fn_rank_one: impl Fn(&S, BufferID, &Interval) -> Result, + &self, state: &S, - selection: &Selection, + fn_rank_zero: impl Fn(&S, BufferID, usize) -> Result + 'static, + fn_rank_one: impl Fn(&S, BufferID, &Interval) -> Result + 'static, ) -> Result> where E: std::error::Error + 'static, @@ -289,7 +298,7 @@ impl Selection { .collect::>() }; - match selection { + match self { &Self::Position { buffer_id, pos } => { fn_rank_zero(state, buffer_id, pos).map_err(ProcessingError) } -- cgit v1.2.3