mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
AK: Add an extension to construct an AK.String from a Swift.String
This commit is contained in:
committed by
Andrew Kaster
parent
a95f761cb4
commit
458167935c
@@ -23,6 +23,14 @@ extension Swift.String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension AK.String {
|
||||||
|
public init(swiftString: consuming Swift.String) {
|
||||||
|
self.init() // Create empty string first, using default constructor
|
||||||
|
swiftString.withUTF8 { buffer in
|
||||||
|
self = AK.String.from_utf8_without_validation(AK.ReadonlyBytes(buffer.baseAddress!, buffer.count))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
extension AK.StringView: ExpressibleByStringLiteral {
|
extension AK.StringView: ExpressibleByStringLiteral {
|
||||||
public typealias StringLiteralType = Swift.StaticString
|
public typealias StringLiteralType = Swift.StaticString
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user