diff options
| author | tslil <tslil@posteo.de> | 2025-10-28 20:14:27 +0000 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2025-10-28 21:49:26 +0000 |
| commit | 2832ffbe077230b89222479da8b737142c9efe1b (patch) | |
| tree | 2117fcd989859619fdbf59a59d72a67621c43667 /rprt-engine/src/selection.rs | |
| parent | 7c36fb82df24cfa96ad2d2bf3fa769142c178fc1 (diff) | |
Playing with macro_rules, sigh.
Diffstat (limited to 'rprt-engine/src/selection.rs')
| -rw-r--r-- | rprt-engine/src/selection.rs | 17 |
1 files changed, 13 insertions, 4 deletions
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<E> From<E> for VectoriseError<E> +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<S, E>( - fn_rank_zero: impl Fn(&S, BufferID, usize) -> Result<Selection, E>, - fn_rank_one: impl Fn(&S, BufferID, &Interval) -> Result<Selection, E>, + &self, state: &S, - selection: &Selection, + fn_rank_zero: impl Fn(&S, BufferID, usize) -> Result<Selection, E> + 'static, + fn_rank_one: impl Fn(&S, BufferID, &Interval) -> Result<Selection, E> + 'static, ) -> Result<Selection, VectoriseError<E>> where E: std::error::Error + 'static, @@ -289,7 +298,7 @@ impl Selection { .collect::<Result<_, _>>() }; - match selection { + match self { &Self::Position { buffer_id, pos } => { fn_rank_zero(state, buffer_id, pos).map_err(ProcessingError) } |
