Skip to content

Commit c8cb37f

Browse files
authored
Derive Copy trait to SizeHint struct (#164)
The struct has only a size of 24 bytes and is trivially copy-able.
1 parent 915d6d5 commit c8cb37f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

http-body/src/size_hint.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
///
55
/// * 0 for `lower`
66
/// * `None` for `upper`.
7-
#[derive(Debug, Default, Clone)]
7+
#[derive(Debug, Default, Clone, Copy)]
88
pub struct SizeHint {
99
lower: u64,
1010
upper: Option<u64>,
@@ -178,7 +178,7 @@ fn size_hint_addition_basic() {
178178
let exact_l = SizeHint::with_exact(20);
179179
let exact_r = SizeHint::with_exact(5);
180180

181-
assert_eq!(Some(25), (exact_l.clone() + exact_r).exact());
181+
assert_eq!(Some(25), (exact_l + exact_r).exact());
182182

183183
let inexact_l = SizeHint {
184184
lower: 25,
@@ -189,12 +189,12 @@ fn size_hint_addition_basic() {
189189
upper: Some(50),
190190
};
191191

192-
let inexact = inexact_l + inexact_r.clone();
192+
let inexact = inexact_l + inexact_r;
193193

194194
assert_eq!(inexact.lower(), 35);
195195
assert_eq!(inexact.upper(), None);
196196

197-
let exact_inexact = exact_l.clone() + inexact_r.clone();
197+
let exact_inexact = exact_l + inexact_r;
198198

199199
assert_eq!(exact_inexact.lower(), 30);
200200
assert_eq!(exact_inexact.upper(), Some(70));

http-body/tests/is_end_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl Body for Mock {
1818
}
1919

2020
fn size_hint(&self) -> SizeHint {
21-
self.size_hint.clone()
21+
self.size_hint
2222
}
2323
}
2424

0 commit comments

Comments
 (0)