@@ -169,6 +169,62 @@ func _rethrowsViaClosure(_ fn: () throws -> ()) rethrows {
169
169
try fn ( )
170
170
}
171
171
172
+ /// A type whose values can be implicitly or explicitly copied.
173
+ ///
174
+ /// Conforming to this protocol indicates that a type's value can be copied;
175
+ /// this protocol doesn’t have any required methods or properties.
176
+ /// You don't generally need to write an explicit conformance to `Copyable`.
177
+ /// The following places implicitly include `Copyable` conformance:
178
+ ///
179
+ /// * Structure declarations,
180
+ /// unless it has a noncopyable stored property
181
+ /// * Enumeration declarations,
182
+ /// unless it has a case whose associated value isn't copyable
183
+ /// * Class declarations
184
+ /// * Actor declarations
185
+ /// * Protocol declarations
186
+ /// * Associated type declarations
187
+ /// * The `Self` type in a protocol extension
188
+ /// * In an extension, the generic parameters of the type being extended
189
+ ///
190
+ /// A class or actor can contain noncopyable stored properties,
191
+ /// while still being copyable itself ---
192
+ /// classes and actors are copied by retaining and releasing references.
193
+ ///
194
+ /// In a declaration that includes generic type parameters,
195
+ /// each generic type parameter implicitly includes `Copyable`
196
+ /// in its list of requirements.
197
+ /// Metatypes and tuples of copyable types are also implicitly copyable,
198
+ /// as are boxed protocol types.
199
+ /// For example,
200
+ /// all of the following pairs of declarations are equivalent:
201
+ ///
202
+ /// struct MyStructure { }
203
+ /// struct MyStructere: Copyable { }
204
+ ///
205
+ /// protocol MyProtocol { }
206
+ /// protocol MyProtocol: Copyable { }
207
+ ///
208
+ /// protocol AnotherProtocol {
209
+ /// associatedtype MyType
210
+ /// associatedtype MyType: Copyable
211
+ /// }
212
+ ///
213
+ /// func genericFunction<T>(t: T) { }
214
+ /// func genericFunction<T>(t: T) where T: Copyable { }
215
+ ///
216
+ /// let x: any MyProtocol
217
+ /// let x: any MyProtocol & Copyable
218
+ ///
219
+ /// To suppress an implicit conformance to `Copyable` you write `~Copyable`.
220
+ /// For example,
221
+ /// only copyable types can conform to `MyProtocol` in the example above,
222
+ /// but both copyable and noncopyable types
223
+ /// can conform `NoRequirements` in the example below:
224
+ ///
225
+ /// protocol NoRequirements: ~Copyable { }
226
+ ///
227
+ /// Extensions to the `Copyable` protocol are not allowed.
172
228
@_marker public protocol Copyable { }
173
229
174
230
@_documentation ( visibility: internal)
0 commit comments