From 34bea2ee3f31b7d187136a4b782575f3f543e3d8 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 8 Sep 2018 12:07:11 -0700 Subject: [PATCH] Implement Clone to support old compilers Arrays above size 32 are not Clone on old compilers. --- src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 2de79e8..9524f52 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -49,7 +49,7 @@ pub fn fmt(mut wr: W, value: V) -> fmt::Result { /// let printed = buffer.format(1234); /// assert_eq!(printed, "1234"); /// ``` -#[derive(Copy, Clone)] +#[derive(Copy)] pub struct Buffer { 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 { /// This is a cheap operation; you don't need to worry about reusing buffers /// for efficiency.