What to use in swift instead of const references?

Past discussion (briefly) on why Swift doesn’t have C++-style mutability checking for classes:

You need something like Rust’s unique &mut to make the non-mutating methods more than just hints to the reader. Not that hints to the reader aren’t useful, but they weren’t something we considered sufficiently useful in this case to build into the language, especially when many uses of classes with interesting mutability are better expressed as structs in Swift (and a good chunk of the rest would correspond to patterns in Objective-C, which does not have this distinction either).

2 Likes