prowocessing: let-else refatoring as according to review
This commit is contained in:
parent
ddc1f935c6
commit
c900a0f4b3
2 changed files with 18 additions and 24 deletions
|
@ -14,11 +14,10 @@ pub struct Add(pub i32);
|
||||||
impl PipelineElement for Add {
|
impl PipelineElement for Add {
|
||||||
fn runner(&self) -> fn(&Inputs) -> Outputs {
|
fn runner(&self) -> fn(&Inputs) -> Outputs {
|
||||||
|input| {
|
|input| {
|
||||||
if let [DataRef::Int(i0), DataRef::Int(i1), ..] = input.inner()[..] {
|
let [DataRef::Int(i0), DataRef::Int(i1), ..] = input.inner()[..] else {
|
||||||
(i0 + i1).into()
|
|
||||||
} else {
|
|
||||||
panic!("Invalid data passed")
|
panic!("Invalid data passed")
|
||||||
}
|
};
|
||||||
|
(i0 + i1).into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,11 +34,10 @@ pub struct Subtract(pub i32);
|
||||||
impl PipelineElement for Subtract {
|
impl PipelineElement for Subtract {
|
||||||
fn runner(&self) -> fn(&Inputs) -> Outputs {
|
fn runner(&self) -> fn(&Inputs) -> Outputs {
|
||||||
|input| {
|
|input| {
|
||||||
if let [DataRef::Int(i0), DataRef::Int(i1), ..] = input.inner()[..] {
|
let [DataRef::Int(i0), DataRef::Int(i1), ..] = input.inner()[..] else {
|
||||||
(i0 + i1).into()
|
|
||||||
} else {
|
|
||||||
panic!("Invalid data passed")
|
panic!("Invalid data passed")
|
||||||
}
|
};
|
||||||
|
(i0 + i1).into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,11 +54,10 @@ pub struct Stringify;
|
||||||
impl PipelineElement for Stringify {
|
impl PipelineElement for Stringify {
|
||||||
fn runner(&self) -> fn(&Inputs) -> Outputs {
|
fn runner(&self) -> fn(&Inputs) -> Outputs {
|
||||||
|input| {
|
|input| {
|
||||||
if let [DataRef::Int(int), ..] = input.inner()[..] {
|
let [DataRef::Int(int), ..] = input.inner()[..] else {
|
||||||
int.to_string().into()
|
|
||||||
} else {
|
|
||||||
panic!("Invalid data passed")
|
panic!("Invalid data passed")
|
||||||
}
|
};
|
||||||
|
int.to_string().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,10 @@ pub struct Concatenate(pub String);
|
||||||
impl PipelineElement for Concatenate {
|
impl PipelineElement for Concatenate {
|
||||||
fn runner(&self) -> fn(&Inputs) -> Outputs {
|
fn runner(&self) -> fn(&Inputs) -> Outputs {
|
||||||
|input| {
|
|input| {
|
||||||
if let [DataRef::String(s0), DataRef::String(s1), ..] = input.inner()[..] {
|
let [DataRef::String(s0), DataRef::String(s1), ..] = input.inner()[..] else {
|
||||||
format!("{s0}{s1}").into()
|
|
||||||
} else {
|
|
||||||
panic!("Invalid data passed")
|
panic!("Invalid data passed")
|
||||||
}
|
};
|
||||||
|
format!("{s0}{s1}").into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,11 +32,10 @@ pub struct Upper;
|
||||||
impl PipelineElement for Upper {
|
impl PipelineElement for Upper {
|
||||||
fn runner(&self) -> fn(&Inputs) -> Outputs {
|
fn runner(&self) -> fn(&Inputs) -> Outputs {
|
||||||
|input| {
|
|input| {
|
||||||
if let [DataRef::String(s), ..] = input.inner()[..] {
|
let [DataRef::String(s), ..] = input.inner()[..] else {
|
||||||
s.to_uppercase().into()
|
|
||||||
} else {
|
|
||||||
panic!("Invalid data passed")
|
panic!("Invalid data passed")
|
||||||
}
|
};
|
||||||
|
s.to_uppercase().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,11 +52,10 @@ pub struct Lower;
|
||||||
impl PipelineElement for Lower {
|
impl PipelineElement for Lower {
|
||||||
fn runner(&self) -> fn(&Inputs) -> Outputs {
|
fn runner(&self) -> fn(&Inputs) -> Outputs {
|
||||||
|input| {
|
|input| {
|
||||||
if let [DataRef::String(s), ..] = input.inner()[..] {
|
let [DataRef::String(s), ..] = input.inner()[..] else {
|
||||||
s.to_lowercase().into()
|
|
||||||
} else {
|
|
||||||
panic!("Invalid data passed")
|
panic!("Invalid data passed")
|
||||||
}
|
};
|
||||||
|
s.to_lowercase().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue