From b2e54a61ad852fcc456f07cb79939f443d610f24 Mon Sep 17 00:00:00 2001
From: Philipp Oppermann <dev@phil-opp.com>
Date: Sun, 21 Apr 2024 13:39:43 +0200
Subject: [PATCH] Add support for nested `map_field` operations

---
 src/volatile_ptr/macros.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/volatile_ptr/macros.rs b/src/volatile_ptr/macros.rs
index 3e463f9..86633fb 100644
--- a/src/volatile_ptr/macros.rs
+++ b/src/volatile_ptr/macros.rs
@@ -32,17 +32,17 @@
 /// ```
 #[macro_export]
 macro_rules! map_field {
-    ($volatile:ident.$place:ident) => {{
+    ($volatile:ident.$($place:ident).+) => {{
         // Simulate creating a reference to the field. This is done to make
         // sure that the field is not potentially unaligned. The body of the
         // if statement will never be executed, so it can never cause any UB.
         if false {
-            let _ref_to_field = &(unsafe { &*$volatile.as_raw_ptr().as_ptr() }).$place;
+            let _ref_to_field = &(unsafe { &*$volatile.as_raw_ptr().as_ptr() }).$($place).+;
         }
 
         unsafe {
             $volatile.map(|ptr| {
-                core::ptr::NonNull::new(core::ptr::addr_of_mut!((*ptr.as_ptr()).$place)).unwrap()
+                core::ptr::NonNull::new(core::ptr::addr_of_mut!((*ptr.as_ptr()).$($place).+)).unwrap()
             })
         }
     }};