aboutsummaryrefslogtreecommitdiff
path: root/rprt-engine/src/selection.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rprt-engine/src/selection.rs')
-rw-r--r--rprt-engine/src/selection.rs17
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)
}