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