clean up code
This commit is contained in:
parent
ba92ea03b3
commit
cce0b5ec41
1 changed files with 16 additions and 36 deletions
52
src/lib.rs
52
src/lib.rs
|
@ -19,46 +19,26 @@ pub struct CmdOutput {
|
|||
impl CmdOutput {
|
||||
/// Returns only stdout
|
||||
pub fn stdout(self) -> Option<Vec<Line>> {
|
||||
match self.lines {
|
||||
Some(lines) => {
|
||||
return Some(
|
||||
lines
|
||||
.into_iter()
|
||||
.filter(|l| {
|
||||
if l.printed_to == LineType::Stdout {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
}
|
||||
None => {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
self.lines.and_then(|lines| {
|
||||
Some(
|
||||
lines
|
||||
.into_iter()
|
||||
.filter(|line| line.printed_to == LineType::Stdout)
|
||||
.collect(),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns only stdout
|
||||
pub fn stderr(self) -> Option<Vec<Line>> {
|
||||
match self.lines {
|
||||
Some(lines) => {
|
||||
return Some(
|
||||
lines
|
||||
.into_iter()
|
||||
.filter(|l| {
|
||||
if l.printed_to == LineType::Stderr {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
}
|
||||
None => {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
self.lines.and_then(|lines| {
|
||||
Some(
|
||||
lines
|
||||
.into_iter()
|
||||
.filter(|line| line.printed_to == LineType::Stderr)
|
||||
.collect(),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns all output
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue