alexisakers / HTMLString

Escape and unescape HTML entities in Swift
MIT License
170 stars 69 forks source link

Fix compile error about optional value #13

Closed DaemonF closed 5 years ago

DaemonF commented 5 years ago

This line currently fails to compile if called on a String.UTF8View or String.UTF16View.

String(Substring) always returns a valid value, but String(Substring.UTF8View) or the same for UTF16View will return nil if the argument is not valid UTF8 or UTF16. Since we know self is valid, we can safely assert that a substring of self is valid and that the String initializer will return non-nil.

DaemonF commented 5 years ago

Actually, it looks like this is due to an issue with the SWIFT_VERSION config and this is being compiled as Swift 3 in my project. I'll put out a different pull request once I've tracked down the appropriate fix.