Skip to content

Fix URL.Template availability annotations #1279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Sources/FoundationEssentials/URL/URLTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ extension URL {

// MARK: - Parse
#if FOUNDATION_FRAMEWORK
@available(FoundationPreview 6.2, *)
extension URL.Template {
/// Creates a new template from its text form.
///
Expand Down Expand Up @@ -168,6 +169,7 @@ extension URL.Template {

// MARK: -

@available(FoundationPreview 6.2, *)
extension URL.Template: CustomStringConvertible {
public var description: String {
elements.reduce(into: "") {
Expand Down
6 changes: 6 additions & 0 deletions Sources/FoundationEssentials/URL/URLTemplate_Value.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal import OrderedCollections
internal import _FoundationCollections
#endif

@available(FoundationPreview 6.2, *)
extension URL.Template {
/// The value of a variable used for expanding a template.
///
Expand Down Expand Up @@ -49,6 +50,7 @@ extension URL.Template {
}
}

@available(FoundationPreview 6.2, *)
extension URL.Template.Value {
/// A text value to be used with a ``URL.Template``.
public static func text(_ text: String) -> URL.Template.Value {
Expand All @@ -68,18 +70,21 @@ extension URL.Template.Value {

// MARK: -

@available(FoundationPreview 6.2, *)
extension URL.Template.Value: ExpressibleByStringLiteral {
public init(stringLiteral value: String) {
self = .text(value)
}
}

@available(FoundationPreview 6.2, *)
extension URL.Template.Value: ExpressibleByArrayLiteral {
public init(arrayLiteral elements: String...) {
self.init(underlying: .list(elements))
}
}

@available(FoundationPreview 6.2, *)
extension URL.Template.Value: ExpressibleByDictionaryLiteral {
public init(dictionaryLiteral elements: (String, String)...) {
self.init(underlying: .associativeList(OrderedDictionary(uniqueKeysWithValues: elements)))
Expand All @@ -88,6 +93,7 @@ extension URL.Template.Value: ExpressibleByDictionaryLiteral {

// MARK: -

@available(FoundationPreview 6.2, *)
extension URL.Template.Value: CustomStringConvertible {
public var description: String {
switch underlying {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//

@available(FoundationPreview 6.2, *)
extension URL.Template {
/// The name of a variable used for expanding a template.
public struct VariableName: Sendable, Hashable {
Expand All @@ -34,6 +35,7 @@ extension String {
}
}

@available(FoundationPreview 6.2, *)
extension URL.Template.VariableName: CustomStringConvertible {
public var description: String {
String(self)
Expand Down