So Objective-C has the following methods of NSString
:
- initWithContentsOfFile:encoding:error:
- writeToFile:atomically:encoding:error:
These are directly bridged to Swift's NSString
:
convenience init(contentsOfFile path: String, encoding enc: UInt)
func write(toFile path: String, atomically useAuxiliaryFile: Bool, encoding enc: UInt)
Having seen an example of these functions used directly with Swift's String
type I see that String
has:
init(contentsOfFile path: String, encoding enc: String.Encoding)
While StringProtocol
has:
write<T>(toFile path: T, atomically useAuxiliaryFile: Bool, encoding enc: String.Encoding) throws where T : StringProtocol
My issue is not with their definitions or usage, but with their discovery via documentation. Specifically, for the write
in StringProtocol
. Since this method can be used both on String
and Substring
, shouldn't they be documented under those structures as well and not just the StringProtocol
protocol?
I imagine this is not the only case like this...