Skip to content

Commit 0ddf8b1

Browse files
committed
Bump version for release and a few clippy warnings fixed
1 parent d236736 commit 0ddf8b1

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "redis-async"
3-
version = "0.4.2"
3+
version = "0.4.3"
44
authors = ["Ben Ashford <[email protected]>"]
55
license = "MIT/Apache-2.0"
66
readme = "README.md"

examples/monitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use redis_async::client;
2222
fn main() {
2323
let addr = env::args()
2424
.nth(1)
25-
.unwrap_or("127.0.0.1:6379".to_string())
25+
.unwrap_or_else(|| "127.0.0.1:6379".to_string())
2626
.parse()
2727
.unwrap();
2828

examples/pubsub.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ use redis_async::client;
2020
use redis_async::resp::FromResp;
2121

2222
fn main() {
23-
let topic = env::args().nth(1).unwrap_or("test-topic".to_string());
23+
let topic = env::args()
24+
.nth(1)
25+
.unwrap_or_else(|| "test-topic".to_string());
2426
let addr = env::args()
2527
.nth(2)
26-
.unwrap_or("127.0.0.1:6379".to_string())
28+
.unwrap_or_else(|| "127.0.0.1:6379".to_string())
2729
.parse()
2830
.unwrap();
2931

examples/realistic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn main() {
2929

3030
let addr = env::args()
3131
.nth(1)
32-
.unwrap_or("127.0.0.1:6379".to_string())
32+
.unwrap_or_else(|| "127.0.0.1:6379".to_string())
3333
.parse()
3434
.unwrap();
3535

src/resp.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! An implementation of the RESP protocol
1212
1313
use std::collections::HashMap;
14-
use std::hash::Hash;
14+
use std::hash::{BuildHasher, Hash};
1515
use std::io;
1616
use std::str;
1717

@@ -189,19 +189,21 @@ impl<T: FromResp> FromResp for Vec<T> {
189189
}
190190
}
191191

192-
impl<K: FromResp + Hash + Eq, T: FromResp> FromResp for HashMap<K, T> {
193-
fn from_resp_int(resp: RespValue) -> Result<HashMap<K, T>, Error> {
192+
impl<K: FromResp + Hash + Eq, T: FromResp, S: BuildHasher + Default> FromResp for HashMap<K, T, S> {
193+
fn from_resp_int(resp: RespValue) -> Result<HashMap<K, T, S>, Error> {
194194
match resp {
195195
RespValue::Array(ary) => {
196-
let mut map = HashMap::new();
196+
let mut map = HashMap::with_capacity_and_hasher(ary.len(), S::default());
197197
let mut items = ary.into_iter();
198198

199199
while let Some(k) = items.next() {
200200
let key = K::from_resp(k)?;
201-
let value = T::from_resp(items.next().ok_or(error::resp(
202-
"Cannot convert an odd number of elements into a hashmap",
203-
"".into(),
204-
))?)?;
201+
let value = T::from_resp(items.next().ok_or_else(|| {
202+
error::resp(
203+
"Cannot convert an odd number of elements into a hashmap",
204+
"".into(),
205+
)
206+
})?)?;
205207

206208
map.insert(key, value);
207209
}

0 commit comments

Comments
 (0)