Override clone_from for some types

This commit is contained in:
Benoît du Garreau 2021-05-11 13:00:34 +02:00
parent fe62c6e295
commit 9332ac3bfc
4 changed files with 55 additions and 3 deletions

View file

@ -71,7 +71,7 @@ use core::convert::TryInto;
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
#[derive(Debug, Default, Eq, PartialEq)]
pub struct Cursor<T> {
inner: T,
pos: u64,
@ -205,6 +205,23 @@ impl<T> Cursor<T> {
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Clone for Cursor<T>
where
T: Clone,
{
#[inline]
fn clone(&self) -> Self {
Cursor { inner: self.inner.clone(), pos: self.pos }
}
#[inline]
fn clone_from(&mut self, other: &Self) {
self.inner.clone_from(&other.inner);
self.pos = other.pos;
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> io::Seek for Cursor<T>
where