Skip to content
This repository was archived by the owner on Mar 10, 2022. It is now read-only.

Commit c3d53ef

Browse files
author
Dominik Hadl
committed
Use associated type for the protocol instead of generic constraints on functions
1 parent abfc1f1 commit c3d53ef

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

UserManagerType/UserManagerType.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
//
22
// UserManager.swift
3-
// BorsenMobil
3+
// UserManagerType
44
//
55
// Created by Jakob Mygind on 18/08/15.
6-
// Copyright © 2015 Borsen. All rights reserved.
6+
// Copyright © 2015 Nodes ApS. All rights reserved.
77
//
88

99
import Foundation
1010
import Serializable
1111
import Cashier
1212

13-
public typealias UserType = Serializable
14-
15-
public protocol UserManagerType {}
13+
public protocol UserManagerType {
14+
associatedtype UserType: Serializable
15+
}
1616

1717
public extension UserManagerType {
1818

@@ -21,7 +21,7 @@ public extension UserManagerType {
2121

2222
- Returns: Object that confroms with `UserType` with informations about the current user or `nil`.
2323
*/
24-
public static func currentUser<T:UserType>() -> T? {
24+
public static func currentUser() -> UserType? {
2525
return NOPersistentStore.cacheWithId("UserManager").serializableForKey("User")
2626
}
2727

@@ -30,7 +30,7 @@ public extension UserManagerType {
3030

3131
- Parameter user: The user object that conforms `UserType`.
3232
*/
33-
public static func setCurrentUser<T:UserType>(user:T) {
33+
public static func setCurrentUser(user: UserType) {
3434
NOPersistentStore.cacheWithId("UserManager").setSerializable(user, forKey: "User")
3535
}
3636

0 commit comments

Comments
 (0)