From b8fa1d194238a3f45d5db01d1909ae00577b2af7 Mon Sep 17 00:00:00 2001
From: Jonathan 'theJPster' Pallant <github@thejpster.org.uk>
Date: Sat, 15 Oct 2016 18:48:19 +0100
Subject: [PATCH] Add modify method to RW.

---
 Cargo.toml | 7 +++++--
 src/lib.rs | 7 +++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index de5489f..04019d8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,9 +1,12 @@
 [package]
-authors = ["Jorge Aparicio <japaricious@gmail.com>"]
+authors = [
+	"Jorge Aparicio <japaricious@gmail.com>",
+	"Jonathan 'theJPster' Pallant <github@thejpster.org.uk>"
+]
 description = "Volatile access to memory mapped hardware registers"
 documentation = "https://docs.rs/volatile-register"
 keywords = ["volatile", "register"]
 license = "MIT OR Apache-2.0"
 name = "volatile-register"
 repository = "https://github.com/japaric/volatile-register"
-version = "0.1.1"
+version = "0.1.2"
diff --git a/src/lib.rs b/src/lib.rs
index d170994..83274c3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -78,6 +78,13 @@ impl<T> RW<T>
             ptr::write_volatile(&mut self.register, value);
         }
     }
+
+    /// Perform a read-modify-write, using `func` to perform the modification.
+    pub fn modify<F>(&mut self, func: F) where F: FnOnce(T) -> T {
+        let mut t = self.read();
+        t = func(t);
+        self.write(t);
+    }
 }
 
 /// Write-Only register
-- 
GitLab