Implement Clone to support old compilers

Arrays above size 32 are not Clone on old compilers.
This commit is contained in:
David Tolnay 2018-09-08 12:07:11 -07:00
parent de113feb96
commit 34bea2ee3f
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
1 changed files with 8 additions and 1 deletions

View File

@ -49,7 +49,7 @@ pub fn fmt<W: fmt::Write, V: Integer>(mut wr: W, value: V) -> fmt::Result {
/// let printed = buffer.format(1234); /// let printed = buffer.format(1234);
/// assert_eq!(printed, "1234"); /// assert_eq!(printed, "1234");
/// ``` /// ```
#[derive(Copy, Clone)] #[derive(Copy)]
pub struct Buffer { pub struct Buffer {
bytes: [u8; I128_MAX_LEN], bytes: [u8; I128_MAX_LEN],
} }
@ -61,6 +61,13 @@ impl Default for Buffer {
} }
} }
impl Clone for Buffer {
#[inline]
fn clone(&self) -> Self {
Buffer::new()
}
}
impl Buffer { impl Buffer {
/// This is a cheap operation; you don't need to worry about reusing buffers /// This is a cheap operation; you don't need to worry about reusing buffers
/// for efficiency. /// for efficiency.