Skip to content

Commit

Permalink
#4 Created a Swift Package version of this repo, fixed forgotten vers…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
KyNorthstar committed Aug 11, 2019
1 parent 4029360 commit e5cb247
Show file tree
Hide file tree
Showing 10 changed files with 775 additions and 9 deletions.
5 changes: 5 additions & 0 deletions LazyContainers/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
28 changes: 28 additions & 0 deletions LazyContainers/Package.swift
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"]),
]
)
8 changes: 8 additions & 0 deletions LazyContainers/README.md
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.
Loading

0 comments on commit e5cb247

Please sign in to comment.