Skip to content

Commit dcc3214

Browse files
Michael Brenanphil-opp
authored andcommitted
Change ReadWrite to a type alias (#4)
Fixes #2
1 parent 356809c commit dcc3214

File tree

1 file changed

+3
-53
lines changed

1 file changed

+3
-53
lines changed

src/lib.rs

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -203,61 +203,11 @@ impl<T: Copy> WriteOnly<T> {
203203
}
204204

205205
/// A volatile wrapper which allows both read and write operations;
206-
/// functionally equivalent to the `Volatile` type.
206+
/// functionally equivalent to the `Volatile` type, as it is a type
207+
/// alias for it.
207208
///
208209
/// The size of this struct is the same as the contained type.
209-
#[derive(Debug)]
210-
pub struct ReadWrite<T: Copy>(Volatile<T>);
211-
212-
impl<T: Copy> ReadWrite<T> {
213-
/// Construct a new read-write volatile wrapper containing the given value.
214-
///
215-
/// ```rust
216-
/// use volatile::ReadWrite;
217-
///
218-
/// let value = ReadWrite::new(0u32);
219-
/// ```
220-
///
221-
/// # Panics
222-
///
223-
/// This function never panics.
224-
pub fn new(value: T) -> ReadWrite<T> {
225-
ReadWrite(Volatile(value))
226-
}
227-
228-
/// Perform a volatile read of the contained value and return a copy of the read value.
229-
/// Functionally identical to `Volatile::read`.
230-
///
231-
/// # Panics
232-
///
233-
/// This function never panics.
234-
pub fn read(&self) -> T {
235-
self.0.read()
236-
}
237-
238-
/// Peform a volatile write of value `value` into the contained value. Functionally identical
239-
/// to `Volatile::write`.
240-
///
241-
/// # Panics
242-
///
243-
/// This function never panics.
244-
pub fn write(&mut self, value: T) {
245-
self.0.write(value)
246-
}
247-
248-
/// Perform a volatile read of the contained value, pass a mutable reference to it to function
249-
/// `f`, and then perform a volatile write back of the (potentially updated) value to the contained
250-
/// value. Functionally identical to `Volatile::update`.
251-
///
252-
/// # Panics
253-
///
254-
/// This function never panics.
255-
pub fn update<F>(&mut self, f: F)
256-
where F: FnOnce(&mut T)
257-
{
258-
self.0.update(f)
259-
}
260-
}
210+
pub type ReadWrite<T> = Volatile<T>;
261211

262212
#[cfg(test)]
263213
mod tests {

0 commit comments

Comments
 (0)