> On 11. Oct 2017, at 22:11, Guillaume Lessard <gless...@tffenterprises.com> > wrote: > > >> On Oct 10, 2017, at 01:50, Martin R via swift-users <swift-users@swift.org> >> wrote: >> >> Thank you Howard for you response! However, I have a follow-up question: >> >> Why are UnsafeMutableBufferPointer methods which modify not the buffer >> pointer itself, but only the pointed-to memory, mutating at all? > > Don’t forget that UnsafeMutableBufferPointer conforms to MutableCollection, > and that many MutableCollection methods (such as swapAt) must be mutating. > The BufferPointer types are unusual among Collection conformers in not having > value semantics. > > Cheers, > Guillaume Lessard >
But an implementation of a mutating protocol method does not have to be mutating: protocol Foo { mutating func test() } struct Bar: Foo { func test() { } } let bar = Bar() bar.test() Isn't that a similar situation as with the subscript setter, which is mutating in general for MutableCollection, but non-mutating for UnsafeMutableBufferPointer? Martin _______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users