Skip to content

Commit 81d2dcd

Browse files
committed
apply rustfmt guidelines
1 parent 419e215 commit 81d2dcd

File tree

14 files changed

+229
-330
lines changed

14 files changed

+229
-330
lines changed

src/client.rs

Lines changed: 98 additions & 167 deletions
Large diffs are not rendered by default.

src/error.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ impl FromStr for ServerError {
142142
let command = s[left_brace + 1..right_brace].to_string();
143143
let detail = s[right_brace + 1..].trim().to_string();
144144
Ok(ServerError {
145-
code: code,
146-
pos: pos,
147-
command: command,
148-
detail: detail,
149-
})
145+
code: code,
146+
pos: pos,
147+
command: command,
148+
detail: detail,
149+
})
150150
} else {
151151
Err(ParseError::NoMessage)
152152
}

src/idle.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ pub struct IdleGuard<'a, S: 'a + Read + Write>(&'a mut Client<S>);
124124
impl<'a, S: 'a + Read + Write> IdleGuard<'a, S> {
125125
/// Get list of subsystems with new events, interrupting idle mode in process
126126
pub fn get(self) -> Result<Vec<Subsystem>, Error> {
127-
let result = self.0
128-
.read_list("changed")
129-
.and_then(|v| v.into_iter().map(|b| b.parse().map_err(From::from)).collect());
127+
let result = self.0.read_list("changed").and_then(|v| v.into_iter().map(|b| b.parse().map_err(From::from)).collect());
130128
forget(self);
131129
result
132130
}

src/message.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,9 @@ pub struct Message {
2727
impl FromMap for Message {
2828
fn from_map(map: BTreeMap<String, String>) -> Result<Message, Error> {
2929
Ok(Message {
30-
channel: Channel(try!(map.get("channel")
31-
.map(|v| v.to_owned())
32-
.ok_or(Error::Proto(ProtoError::NoField("channel"))))),
33-
message: try!(map.get("message")
34-
.map(|v| v.to_owned())
35-
.ok_or(Error::Proto(ProtoError::NoField("message")))),
36-
})
30+
channel: Channel(try!(map.get("channel").map(|v| v.to_owned()).ok_or(Error::Proto(ProtoError::NoField("channel"))))),
31+
message: try!(map.get("message").map(|v| v.to_owned()).ok_or(Error::Proto(ProtoError::NoField("message")))),
32+
})
3733
}
3834
}
3935

@@ -70,8 +66,8 @@ impl Channel {
7066
/// numbers (`0`-`9`), underscore, forward slash, dot and colon (`_`, `/`, `.`, `:`)
7167
pub fn is_valid_name(name: &str) -> bool {
7268
name.bytes().all(|b| {
73-
(0x61 <= b && b <= 0x7a) || (0x41 <= b && b <= 0x5a) || (0x30 <= b && b <= 0x39) ||
74-
(b == 0x5f || b == 0x2f || b == 0x2e || b == 0x3a)
75-
})
69+
(0x61 <= b && b <= 0x7a) || (0x41 <= b && b <= 0x5a) || (0x30 <= b && b <= 0x39) ||
70+
(b == 0x5f || b == 0x2f || b == 0x2e || b == 0x3a)
71+
})
7672
}
7773
}

src/mount.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,9 @@ pub struct Mount {
2626
impl FromMap for Mount {
2727
fn from_map(map: BTreeMap<String, String>) -> Result<Mount, Error> {
2828
Ok(Mount {
29-
name: try!(map.get("mount")
30-
.map(|s| s.to_owned())
31-
.ok_or(Error::Proto(ProtoError::NoField("mount")))),
32-
storage: try!(map.get("storage")
33-
.map(|s| s.to_owned())
34-
.ok_or(Error::Proto(ProtoError::NoField("storage")))),
35-
})
29+
name: try!(map.get("mount").map(|s| s.to_owned()).ok_or(Error::Proto(ProtoError::NoField("mount")))),
30+
storage: try!(map.get("storage").map(|s| s.to_owned()).ok_or(Error::Proto(ProtoError::NoField("storage")))),
31+
})
3632
}
3733
}
3834

@@ -48,12 +44,8 @@ pub struct Neighbor {
4844
impl FromMap for Neighbor {
4945
fn from_map(map: BTreeMap<String, String>) -> Result<Neighbor, Error> {
5046
Ok(Neighbor {
51-
name: try!(map.get("name")
52-
.map(|s| s.to_owned())
53-
.ok_or(Error::Proto(ProtoError::NoField("name")))),
54-
storage: try!(map.get("neighbor")
55-
.map(|s| s.to_owned())
56-
.ok_or(Error::Proto(ProtoError::NoField("neighbor")))),
57-
})
47+
name: try!(map.get("name").map(|s| s.to_owned()).ok_or(Error::Proto(ProtoError::NoField("name")))),
48+
storage: try!(map.get("neighbor").map(|s| s.to_owned()).ok_or(Error::Proto(ProtoError::NoField("neighbor")))),
49+
})
5850
}
5951
}

src/output.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ pub struct Output {
2020
impl FromMap for Output {
2121
fn from_map(map: BTreeMap<String, String>) -> Result<Output, Error> {
2222
Ok(Output {
23-
id: get_field!(map, "outputid"),
24-
name: try!(map.get("outputname")
25-
.map(|v| v.to_owned())
26-
.ok_or(Error::Proto(ProtoError::NoField("outputname")))),
27-
enabled: get_field!(map, bool "outputenabled"),
28-
})
23+
id: get_field!(map, "outputid"),
24+
name: try!(map.get("outputname").map(|v| v.to_owned()).ok_or(Error::Proto(ProtoError::NoField("outputname")))),
25+
enabled: get_field!(map, bool "outputenabled"),
26+
})
2927
}
3028
}

src/playlist.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ pub struct Playlist {
1818
impl FromMap for Playlist {
1919
fn from_map(map: BTreeMap<String, String>) -> Result<Playlist, Error> {
2020
Ok(Playlist {
21-
name: try!(map.get("playlist")
22-
.map(|v| v.to_owned())
23-
.ok_or(Error::Proto(ProtoError::NoField("playlist")))),
24-
last_mod: try!(map.get("Last-Modified")
21+
name: try!(map.get("playlist").map(|v| v.to_owned()).ok_or(Error::Proto(ProtoError::NoField("playlist")))),
22+
last_mod: try!(map.get("Last-Modified")
2523
.ok_or(Error::Proto(ProtoError::NoField("Last-Modified")))
2624
.and_then(|v| strptime(&*v, "%Y-%m-%dT%H:%M:%S%Z").map_err(From::from))),
27-
})
25+
})
2826
}
2927
}

src/plugin.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ impl FromIter for Vec<Plugin> {
2525
plugin.map(|p| result.push(p));
2626

2727
plugin = Some(Plugin {
28-
name: b,
29-
suffixes: Vec::new(),
30-
mime_types: Vec::new(),
31-
});
28+
name: b,
29+
suffixes: Vec::new(),
30+
mime_types: Vec::new(),
31+
});
3232
}
3333
"mime_type" => {
3434
plugin.as_mut().map(|p| p.mime_types.push(b));

src/proto.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ impl<I> Iterator for Pairs<I>
1919
{
2020
type Item = Result<(String, String)>;
2121
fn next(&mut self) -> Option<Result<(String, String)>> {
22-
let reply: Option<Result<Reply>> = self.0
23-
.next()
24-
.map(|v| v.map_err(Error::Io).and_then(|s| s.parse::<Reply>().map_err(Error::Parse)));
22+
let reply: Option<Result<Reply>> =
23+
self.0.next().map(|v| v.map_err(Error::Io).and_then(|s| s.parse::<Reply>().map_err(Error::Parse)));
2524
match reply {
2625
Some(Ok(Reply::Pair(a, b))) => Some(Ok((a, b))),
2726
None |
@@ -108,16 +107,15 @@ pub trait Proto {
108107
fn read_structs<'a, T>(&'a mut self, key: &'static str) -> Result<Vec<T>>
109108
where T: 'a + FromMap
110109
{
111-
self.read_pairs().split(key).map(|v| v.and_then(FromMap::from_map)).collect()
110+
self.read_pairs()
111+
.split(key)
112+
.map(|v| v.and_then(FromMap::from_map))
113+
.collect()
112114
}
113115

114116
fn read_list(&mut self, key: &'static str) -> Result<Vec<String>> {
115117
self.read_pairs()
116-
.filter(|r| {
117-
r.as_ref()
118-
.map(|&(ref a, _)| *a == key)
119-
.unwrap_or(true)
120-
})
118+
.filter(|r| r.as_ref().map(|&(ref a, _)| *a == key).unwrap_or(true))
121119
.map(|r| r.map(|(_, b)| b))
122120
.collect()
123121
}

src/search.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ impl<'a> Query<'a> {
6464
impl<'a> fmt::Display for Term<'a> {
6565
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6666
f.write_str(match *self {
67-
Term::Any => "any",
68-
Term::File => "file",
69-
Term::Base => "base",
70-
Term::LastMod => "modified-since",
71-
Term::Tag(ref tag) => &*tag,
72-
})
67+
Term::Any => "any",
68+
Term::File => "file",
69+
Term::Base => "base",
70+
Term::LastMod => "modified-since",
71+
Term::Tag(ref tag) => &*tag,
72+
})
7373
}
7474
}
7575

@@ -134,8 +134,7 @@ mod test {
134134
#[test]
135135
fn find_query_format() {
136136
let mut query = Query::new();
137-
let finished = query.and(Term::Tag("albumartist".into()), "Mac DeMarco")
138-
.and(Term::Tag("album".into()), "Salad Days");
137+
let finished = query.and(Term::Tag("albumartist".into()), "Mac DeMarco").and(Term::Tag("album".into()), "Salad Days");
139138
let output = collect(&*finished);
140139
assert_eq!(output, vec!["albumartist", "Mac DeMarco", "album", "Salad Days"]);
141140
}

0 commit comments

Comments
 (0)