Created
June 7, 2022 17:50
-
-
Save markiv/fb0bf59bdaca07c13f59990df780a8f2 to your computer and use it in GitHub Desktop.
This file contains 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
prefix operator ^ | |
postfix operator ^ | |
extension URL: ExpressibleByStringLiteral { | |
/// Conveniently initializes a `URL` from a string literal: | |
/// | |
/// let url: URL = "https://www.somewhere.com" | |
public init(stringLiteral value: StringLiteralType) { | |
self.init(string: value)! | |
} | |
/// Conveniently initializes a `URL` from a string literal: | |
/// | |
/// let url = URL("https://www.somewhere.com") | |
public init(_ value: StringLiteralType) { | |
self.init(string: value)! | |
} | |
/// This operator conveniently initializes a `URL` from a prefixed string literal: | |
/// | |
/// let url = ^"https://www.somewhere.com" | |
@inlinable @inline(__always) | |
static prefix func ^ (_ value: URL) -> URL { value } | |
/// This operator conveniently initializes a `URL` from a postfixed string literal: | |
/// | |
/// let url = "https://www.somewhere.com"^ | |
@inlinable @inline(__always) | |
static postfix func ^ (_ value: URL) -> URL { value } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment