SE-0494: Add `isIdentical(to:)` Methods for Quick Comparisons to Concrete Types

Let's maybe try this from another direction… here is the feedback from LSG that suggested we choose isTriviallyIdentical(to:):

Let's maybe try and focus on point number one: "triviality".

The isTriviallyIdentical(to:) method on String will not be memcmp. This was discussed in one of our pitch threads:

If the feedback from LSG is we want to ship isTriviallyIdentical(to:) on String… then the feedback from LSG is that all that code I linked to falls under the "umbrella of triviality".

So let's look at Span. Here is the actual shipping implementation of isIdentical(to:) on Span:

That's it. One line of code performing an O(1) operation.

So again… all that code and all that conditional logic from String I linked to we are prepared to ship under the umbrella of triviality. But the feedback now is that one line of code — literally one line of code — from Span is somehow… not trivial? How can this be possible?


  1. not meant to be a normative requirement, and without meaning to open discussion about padding ↩︎