mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK: Add an extension to construct an AK.String from a Swift.String
This commit is contained in:
parent
a95f761cb4
commit
458167935c
Notes:
github-actions[bot]
2024-11-19 21:54:54 +00:00
Author: https://github.com/ADKaster Commit: https://github.com/LadybirdBrowser/ladybird/commit/458167935c7 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2386 Reviewed-by: https://github.com/alimpfard
1 changed files with 8 additions and 0 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue