Created
July 25, 2017 05:46
-
-
Save Qata/992a66b224e583ffea8bf65ffbcb9b87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Plain {} | |
enum Encoded {} | |
enum Decompressed {} | |
enum Compressed {} | |
struct Bytes<A, B> { | |
let string: String | |
} | |
extension Bytes where A == Plain, B == Decompressed { | |
func encode() -> Bytes<Encoded, Decompressed> { | |
return Bytes<Encoded, Decompressed>(string: string.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) ?? "") | |
} | |
} | |
extension Bytes where A == Encoded, B == Decompressed { | |
func encode() -> Bytes<Plain, Decompressed> { | |
return Bytes<Plain, Decompressed>(string: string.removingPercentEncoding ?? "") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment