Avatar
omochimetaru 12/2/2025 1:23 PM
Introduction mutating methods require the caller to ensure that the location passed as self can only be accessed through self. This guarantee of exclusive access is a very strong property that can be used by carefully written types like MutableSpan to achieve higher-level safety guarantees. However, operations that want exclusive access are not ...
1:24 PM
borrowing, inout, consumingに続く新たなオーナーシップ指定子のexclusiveの提案
1:25 PM
引数変数自体は変更できなくて、呼び出し側から見ると値渡しだけど、メンバーに関してはmutatingを呼び出せる、というものらしい
1:25 PM
値型セマンティクスだとこれはナンセンスだけど、参照セマンティクスなら意味があって、
1:26 PM
MutatingSpanの利用でこれが欲しくなるらしい
1:26 PM
MutatingSpan自体は変更できないがその参照先は変更できる状況を表現できる
1:32 PM
borrowingだと共有されうるから参照先の変更はできないけど、exclusiveならそこでユニークだから変更ができる。 一方inoutではないから、渡す側で array.mutableSpan みたいなrvalueを渡せる