3 ms·
From the doc comments: /// Accesses the `Pointee` instance referenced by `self`. /// /// - Precondition: Either the pointee has been initialized with an
by atrick6 10y ago
From the doc comments:
/// Accesses the `Pointee` instance referenced by `self`.
///
/// - Precondition: Either the pointee has been initialized with an
/// instance of type `Pointee`, or `pointee` is being assigned to
/// and `Pointee` is a trivial type.
public var pointee: Pointee
So, `a.pointee = 42` is fine since we all know that `Int` is a trivial type.
- nine_k 10y agoJaywalking when a street is empty is safe; it does not mean that jaywalking is safe in general, and that one should get used to it. In this case, `.initialize` is likely also faster because any previous-value-checking logic than might be there is explicitly not used.
- mikeash 10y agoWhen it's explicitly allowed by the rules, it's no longer "jaywalking." You're right that it doesn't mean this is safe in general, but the original comment is wrong that you should never do this. What previous-value-checking logic are you referring to? I would expect .pointee = 42 to compile down to a single store instruction.