parent
c095ee2aa0
commit
dea9398e08
1 changed files with 12 additions and 5 deletions
17
src/parse.rs
17
src/parse.rs
|
|
@ -25,9 +25,13 @@ unsafe fn parse_many<T, F>(lines: Vec<u8>, mut map: F) -> ZeroCopyResult<Vec<T>>
|
|||
where
|
||||
F: FnMut(Response<'static>) -> MapOrNot<T>,
|
||||
{
|
||||
let f = |mut lines| {
|
||||
let f = |mut lines: &'static [u8]| {
|
||||
let mut things = Vec::new();
|
||||
loop {
|
||||
if lines.is_empty() {
|
||||
break Ok(things);
|
||||
}
|
||||
|
||||
match imap_proto::parse_response(lines) {
|
||||
IResult::Done(rest, resp) => {
|
||||
lines = rest;
|
||||
|
|
@ -36,10 +40,6 @@ where
|
|||
MapOrNot::Map(t) => things.push(t),
|
||||
MapOrNot::Not(resp) => break Err(resp.into()),
|
||||
}
|
||||
|
||||
if lines.is_empty() {
|
||||
break Ok(things);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
break Err(Error::Parse(ParseError::Invalid(lines.to_vec())));
|
||||
|
|
@ -237,6 +237,13 @@ mod tests {
|
|||
assert_eq!(names[0].name(), "INBOX");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_fetches_empty() {
|
||||
let lines = b"";
|
||||
let fetches = parse_fetches(lines.to_vec()).unwrap();
|
||||
assert!(fetches.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_fetches_test() {
|
||||
let lines = b"\
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue