From b31abb732053762a50ac0ca53d5db1ca12bc1487 Mon Sep 17 00:00:00 2001 From: kageru Date: Sun, 21 Jun 2020 23:11:41 +0200 Subject: [PATCH] simplify split parsing --- src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 30382d4..361ef9d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,7 @@ mod error; use error::{Error, MpdResult}; use itertools::Itertools; mod structs; -pub use structs::{Position, Stats, Status, Track, State}; +pub use structs::{Position, State, Stats, Status, Track}; /// some unprintable character to separate repeated keys const SEPARATOR: char = '\x02'; @@ -18,9 +18,8 @@ pub fn deserialize_response<'a, I: Iterator, T: de::DeserializeO return Err(Error::from_str(message.trim())); } - let mut fields = line.splitn(2, ": "); - match (fields.next(), fields.next()) { - (Some(k), Some(v)) => { + match line.splitn(2, ": ").next_tuple() { + Some((k, v)) => { if let Some(existing) = map.get_mut(k) { existing.push(SEPARATOR); existing.push_str(v);