where I've ensured that XXX and YYY are layout compatible. Note that the buffer pointer is passed as inout, so I could have to copy back any changes to the buffer to the original dummy manually if necessary.
var a: String = "a"
// Get an UnsafeMutablePointer<String>.
withUnsafeMutablePointer(to: &a) { strPtr in
// Get that as a UnsafeMutablePointer<UInt8>.
// This is where we need layout compatability.
strPtr.withMemoryRebound(to: UInt8.self, capacity: 1) { uintPtr in
// Modify it as UInt8.
uintPtr.pointee += 1
}
}
print(a) // prints "b"