<div dir="ltr">Greetings — I haven&#39;t found this specific topic in the archives; apologies if this has come up before.<div><br></div><div>Suppose I have a C struct with an embedded char array:</div><div><br></div><div>struct fileinfo_t {</div><div>    char path[256];</div><div>};</div><div><br></div><div>and I want to convert the path to a Swift String (in order to implement `description`, say).  I would like to use String.init(cString:) for this; but the `path` field is imported as a tuple of 256 `Int8`s, and I need to get an `UnsafePointer&lt;CChar&gt;`.</div><div><br></div><div>So I would like to write something like this:</div><div><br></div><div>extension fileinfo_t: CustomStringConvertible {</div><div>    public var description: String {</div><div>        let path = withUnsafePointer(to: &amp;self.path) {</div><div>            $0.withMemoryRebound(to: CChar.self, capacity: MemoryLayout.size(ofValue: self.path) {</div><div>                $0</div><div>            }</div><div>        }</div><div>        return &quot;fileinfo_t: \(path)&quot;</div><div>    }</div><div>}</div><div><br></div><div>The problem is that `self.path` is immutable, so I can&#39;t pass it to the inout parameter of `withUnsafePointer(to:)`, even though its value is never modified.  I can either (1) write the `description` accessor as `mutating get` — but then it no longer conforms to `CustomStringConvertible` — or (2) copy the `path` field into a local `var` that can be passed to `withUnsafePointer(to:)`, and hope that the compiler can optimize away the copy.</div><div><br></div><div>In the absence of the Swift 4 ownership model (with which I presume this could be marked as a borrowed reference), is (2) the best I can do for now?  And is this the sort of issue that the Ownership Manifesto is designed to address?</div><div><br></div><div>Thanks,</div><div><br></div><div>— Russell Finn</div><div><br></div></div>