Allow initialization from Substring etc.

This commit is contained in:
Max Howell
2019-03-06 12:54:41 -05:00
parent 02fd579f19
commit 8b371fa5d2
3 changed files with 35 additions and 22 deletions

View File

@@ -594,4 +594,14 @@ class PathTests: XCTestCase {
XCTAssertEqual(Path.root.foo.bar.components, ["/", "foo", "bar"])
XCTAssertEqual(Path.root.components, ["/"])
}
func testFlatMap() throws {
// testing compile works
let foo: String? = "/a"
_ = foo.flatMap(Path.init)
let bar: Substring? = "/a"
_ = bar.flatMap(Path.init)
let baz: String.SubSequence? = "/a/b:1".split(separator: ":").first
_ = baz.flatMap(Path.init)
}
}