-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#4 Created a Swift Package version of this repo, fixed forgotten vers…
…ions
- Loading branch information
1 parent
4029360
commit e5cb247
Showing
10 changed files
with
775 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
/*.xcodeproj | ||
xcuserdata/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// swift-tools-version:5.1 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "LazyContainers", | ||
products: [ | ||
// Products define the executables and libraries produced by a package, and make them visible to other packages. | ||
.library( | ||
name: "LazyContainers", | ||
targets: ["LazyContainers"]), | ||
], | ||
dependencies: [ | ||
// Dependencies declare other packages that this package depends on. | ||
// .package(url: /* package url */, from: "1.0.0"), | ||
], | ||
targets: [ | ||
// Targets are the basic building blocks of a package. A target can define a module or a test suite. | ||
// Targets can depend on other targets in this package, and on products in packages which this package depends on. | ||
.target( | ||
name: "LazyContainers", | ||
dependencies: []), | ||
.testTarget( | ||
name: "LazyContainersTests", | ||
dependencies: ["LazyContainers"]), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[![CodeFactor](https://www.codefactor.io/repository/github/rougeware/swift-lazy-patterns/badge)](https://www.codefactor.io/repository/github/rougeware/swift-lazy-patterns) | ||
|
||
# [Lazy Containers](https://github.com/RougeWare/Swift-Lazy-Patterns) # | ||
A few ways to have a lazily-initialized value in Swift 5.1. Note that, if you are OK with the behavior of Swift's `lazy` keyword, you should use that. This is for [those who want very specific behaviors](https://stackoverflow.com/a/40847994/3939277): | ||
|
||
* [`Lazy`](https://github.com/RougeWare/Swift-Lazy-Patterns/blob/master/Lazy.swift#L184-L248): A non-resettable lazy pattern, to guarantee lazy behavior across Swift language versions | ||
* [`ResettableLazy`](https://github.com/RougeWare/Swift-Lazy-Patterns/blob/master/Lazy.swift#L252-L330): A resettable lazy pattern, whose value is generated and cached only when first needed, and can be destroyed when no longer needed. | ||
* [`FunctionalLazy`](https://github.com/RougeWare/Swift-Lazy-Patterns/blob/master/Lazy.swift#L334-L444): An idea about how to approach the lazy pattern by using functions instead of branches. |
Oops, something went wrong.