Skip to content

Commit e9ca8ac

Browse files
committed
Rollup merge of rust-lang#22951 - huonw:weak-chuck-slice, r=alexcrichton
`#[derive(Clone)]` unnecessarily requires the element type to also be `Clone`.
2 parents 393ce18 + 25ad3ba commit e9ca8ac

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/libcore/slice.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,13 +1167,23 @@ forward_iterator! { SplitNMut: T, &'a mut [T] }
11671167
forward_iterator! { RSplitNMut: T, &'a mut [T] }
11681168

11691169
/// An iterator over overlapping subslices of length `size`.
1170-
#[derive(Clone)]
11711170
#[stable(feature = "rust1", since = "1.0.0")]
11721171
pub struct Windows<'a, T:'a> {
11731172
v: &'a [T],
11741173
size: usize
11751174
}
11761175

1176+
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
1177+
#[stable(feature = "rust1", since = "1.0.0")]
1178+
impl<'a, T> Clone for Windows<'a, T> {
1179+
fn clone(&self) -> Windows<'a, T> {
1180+
Windows {
1181+
v: self.v,
1182+
size: self.size,
1183+
}
1184+
}
1185+
}
1186+
11771187
#[stable(feature = "rust1", since = "1.0.0")]
11781188
impl<'a, T> Iterator for Windows<'a, T> {
11791189
type Item = &'a [T];
@@ -1239,13 +1249,23 @@ impl<'a, T> RandomAccessIterator for Windows<'a, T> {
12391249
///
12401250
/// When the slice len is not evenly divided by the chunk size, the last slice
12411251
/// of the iteration will be the remainder.
1242-
#[derive(Clone)]
12431252
#[stable(feature = "rust1", since = "1.0.0")]
12441253
pub struct Chunks<'a, T:'a> {
12451254
v: &'a [T],
12461255
size: usize
12471256
}
12481257

1258+
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
1259+
#[stable(feature = "rust1", since = "1.0.0")]
1260+
impl<'a, T> Clone for Chunks<'a, T> {
1261+
fn clone(&self) -> Chunks<'a, T> {
1262+
Chunks {
1263+
v: self.v,
1264+
size: self.size,
1265+
}
1266+
}
1267+
}
1268+
12491269
#[stable(feature = "rust1", since = "1.0.0")]
12501270
impl<'a, T> Iterator for Chunks<'a, T> {
12511271
type Item = &'a [T];

0 commit comments

Comments
 (0)