-
-
Save astrokin/59db2496d26f239a7f59b847fb327fe7 to your computer and use it in GitHub Desktop.
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
public func with<T>(_ item: inout T, action: (inout T) -> Void) { | |
action(&item) | |
} | |
public func with<T>(_ item: T, action: (T) -> Void) { | |
action(item) | |
} | |
public func with<T: AnyObject>(_ item: T, action: (T) -> Void) { | |
action(item) | |
} | |
/** | |
* Instead of: | |
* | |
* attributes.frame.size = CGSize(width: size.width + 10, height: 23) | |
* attributes.frame.left = attributes.iconViewFrame.right + 8 | |
* attributes.frame.top = 8 | |
* | |
* use: | |
* | |
* with(&attributes.frame) { | |
* $0.size = CGSize(width: size.width + 10, height: 23) | |
* $0.left = attributes.iconViewFrame.right + 8 | |
* $0.top = 8 | |
* } | |
* | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment