Commit Graph

18 Commits

Author SHA1 Message Date
Kuba Mracek
0d4f91f271 [embedded] Add back lazy collection operations, collection diffing and StaticBigInt to Embedded Stdlib 2024-11-16 08:16:57 -08:00
Nate Cook
9265743adc Add validation to CollectionDifference decoder (#76876)
The `CollectionDifference` type has a few different invariants
that were not being validated when initializing using the type's
`Decodable` conformance, since the type was using the
autogenerated `Codable` implementation. This change provides
manual implementations of the `Encodable` and `Decodable`
requirements, and adds tests that validate the failure when trying
to decode invalid JSON for CollectionDifference (and a few other
types).
2024-10-11 17:23:55 -07:00
Karoy Lorentey
8ed81ae063 [stdlib] Adopt availability macros 2021-10-31 15:00:58 -07:00
Karoy Lorentey
dd40ff2929 [stdlib][NFC] Put stored properties & primary initializers before other members in struct declarations 2021-10-05 22:01:35 -07:00
Doug Gregor
9579390024 [SE-0304] Rename ConcurrentValue to Sendable 2021-03-18 22:48:20 -07:00
Doug Gregor
1a1f79c0de Introduce safety checkin for ConcurrentValue conformance.
Introduce checking of ConcurrentValue conformances:
- For structs, check that each stored property conforms to ConcurrentValue
- For enums, check that each associated value conforms to ConcurrentValue
- For classes, check that each stored property is immutable and conforms
  to ConcurrentValue

Because all of the stored properties / associated values need to be
visible for this check to work, limit ConcurrentValue conformances to
be in the same source file as the type definition.

This checking can be disabled by conforming to a new marker protocol,
UnsafeConcurrentValue, that refines ConcurrentValue.
UnsafeConcurrentValue otherwise his no specific meaning. This allows
both "I know what I'm doing" for types that manage concurrent access
themselves as well as enabling retroactive conformance, both of which
are fundamentally unsafe but also quite necessary.

The bulk of this change ended up being to the standard library, because
all conformances of standard library types to the ConcurrentValue
protocol needed to be sunk down into the standard library so they
would benefit from the checking above. There were numerous little
mistakes in the initial pass through the stsandard library types that
have now been corrected.
2021-02-04 03:45:09 -08:00
Scott Perry
3924d1a99d Merge pull request #25825 from numist/numist/diff-inverse-master
add `CollectionDifference.inverse()` and test coverage
2019-07-09 14:46:20 -07:00
Scott Perry
3ddfff92a6 add CollectionDifference.inverse() and test coverage 2019-06-27 11:40:46 -07:00
Scott Perry
0fc5d6ad31 Performance improvements and availability updates for Collection.difference(from:using:) 2019-06-26 16:55:29 -07:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Sho Ikeda
a35c9f0c60 [gardening] Use Collection.isEmpty over Collection.count 2019-05-26 09:35:20 +09:00
Federico Zanetello
afcf4b6991 fix documentation typo (#25061) 2019-05-25 12:43:49 -05:00
Nate Cook
841eb4cf5e [stdlib] Revise collection difference documentation (#24675)
* Revise CollectionDifference documentation.
2019-05-10 20:57:46 +02:00
Scott Perry
6e3139b5da Incorporate feedback from @lorentey and @moiseev 2019-02-27 14:05:06 -08:00
Karoy Lorentey
fd32a3d14e [stdlib] Set availability of diffing APIs 2019-02-22 14:28:15 -08:00
Karoy Lorentey
57f4afbf84 [stdlib] Update diffing code to match stdlib coding conventions
- Add an underscore to private/internal symbols
- Make access levels explicit, even when they’re implied from context
- Conform to max line length of 80 characters
- Conformances declared on separate extensions that implement them
- Arrange member declarations so that stored properties appear first
- Expand single-letter function and type parameter names where there is an obvious name that’s more descriptive
- RangeReplaceableCollection.fastApplicationEnumeration → CollectionDifference._fastEnumeratedApply
2019-02-22 14:27:45 -08:00
Scott Perry
45522918ec Header docs for internal methods validateChanges(_:) and init(validatedChanges:) 2019-02-05 14:34:27 -08:00
Scott Perry
b7f36c3399 Include renamed CollectionDifference.swift 2019-02-04 15:37:22 -08:00