i have a struct
with reference semantics laid out roughly like:
public final
class ExampleState
{
var x:Int
var y:Int
}
public
struct Example
{
let state:ExampleState
let id:Int
let z:[Int]
}
it has:
- properties with shared mutable state (
state.x
,state.y
), which i have put intoExampleState
, - properties that are immutable and do not use reference counting (
id
), and - properties that are immutable, but use reference counting (
z
).
my question is then: are there any benefits or downsides to moving everything into ExampleState
, and making that the new Example
type?
public final
class Example
{
var state:(x:Int, y:Int)
let id:Int
let z:[Int]
}