simplify split parsing
This commit is contained in:
parent
9fb4513fbc
commit
b31abb7320
|
@ -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<Item = &'a str>, 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);
|
||||
|
|
Loading…
Reference in New Issue