Skip to content

Commit 83c2f2e

Browse files
committed
Make clone do a volatile read
1 parent a91aa00 commit 83c2f2e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use core::ptr;
3434
/// take and return copies of the value.
3535
///
3636
/// The size of this struct is the same as the size of the contained type.
37-
#[derive(Debug, Clone)]
37+
#[derive(Debug)]
3838
pub struct Volatile<T: Copy>(T);
3939

4040
impl<T: Copy> Volatile<T> {
@@ -140,6 +140,12 @@ impl<T: Copy> Volatile<T> {
140140
}
141141
}
142142

143+
impl<T: Copy> Clone for Volatile<T> {
144+
fn clone(&self) -> Self {
145+
Volatile(self.read())
146+
}
147+
}
148+
143149
/// A volatile wrapper which only allows read operations.
144150
///
145151
/// The size of this struct is the same as the contained type.

0 commit comments

Comments
 (0)