Skip to content

Commit 0f5e55c

Browse files
tottotoseanmonstar
authored andcommitted
refactor(lib): refactor redundant closure
1 parent 74f38d8 commit 0f5e55c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/extensions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl Extensions {
6161
/// ```
6262
pub fn insert<T: Clone + Send + Sync + 'static>(&mut self, val: T) -> Option<T> {
6363
self.map
64-
.get_or_insert_with(|| Box::new(HashMap::default()))
64+
.get_or_insert_with(Box::default)
6565
.insert(TypeId::of::<T>(), Box::new(val))
6666
.and_then(|boxed| boxed.into_any().downcast().ok().map(|boxed| *boxed))
6767
}
@@ -138,7 +138,7 @@ impl Extensions {
138138
) -> &mut T {
139139
let out = self
140140
.map
141-
.get_or_insert_with(|| Box::new(HashMap::default()))
141+
.get_or_insert_with(Box::default)
142142
.entry(TypeId::of::<T>())
143143
.or_insert_with(|| Box::new(f()));
144144
(**out).as_any_mut().downcast_mut().unwrap()

src/uri/authority.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ impl<'a> TryFrom<&'a [u8]> for Authority {
434434

435435
// Preconditon on create_authority: copy_from_slice() copies all of
436436
// bytes from the [u8] parameter into a new Bytes
437-
create_authority(s, |s| Bytes::copy_from_slice(s))
437+
create_authority(s, Bytes::copy_from_slice)
438438
}
439439
}
440440

0 commit comments

Comments
 (0)