Hacker Newsnew | past | comments | ask | show | jobs | submit | atrick6's commentslogin

Yes, it removes exclusivity checks and bounds checks.


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.


Jaywalking 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.


When 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.


Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: