Skip to content

Commit 90221ab

Browse files
committed
feat: add ExpressibleByLiteral conformances to Length
Add ExpressibleByIntegerLiteral and ExpressibleByFloatLiteral to Length type for cleaner API when constructing lengths from numeric literals. Example usage: let width: W3C_SVG2.Types.Length = 100 // .number(100) let height: W3C_SVG2.Types.Length = 50.5 // .number(50.5) This provides better ergonomics while maintaining type safety.
1 parent 82ea743 commit 90221ab

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Sources/W3C SVG/W3C_SVG2.Types.Length.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,15 @@ extension W3C_SVG2.Types {
102102
}
103103
}
104104
}
105+
106+
extension W3C_SVG2.Types.Length: ExpressibleByIntegerLiteral {
107+
public init(integerLiteral value: Int) {
108+
self = .number(.init(value))
109+
}
110+
}
111+
112+
extension W3C_SVG2.Types.Length: ExpressibleByFloatLiteral {
113+
public init(floatLiteral value: Float) {
114+
self = .number(.init(value))
115+
}
116+
}

0 commit comments

Comments
 (0)