-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #243 from kyleve/kve/no-more-classes-pls
Forbid class types for ItemContent and HeaderFooterContent
- Loading branch information
Showing
4 changed files
with
36 additions
and
0 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
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
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,30 @@ | ||
// | ||
// Validations.swift | ||
// ListableUI | ||
// | ||
// Created by Kyle Van Essen on 12/15/20. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
/// Validates that the provided object is not a class type. | ||
func assertIsValueType<Value>(_ valueType : Value.Type) { | ||
|
||
#if !DEBUG | ||
return | ||
#endif | ||
|
||
precondition( | ||
valueType is AnyClass == false, | ||
{ | ||
let typeName = String(describing: Value.self) | ||
|
||
return """ | ||
`\(typeName)` must be a value type to work properly with Listable and value semantics. Instead, it was a class. | ||
Please convert your `\(typeName)` class from a `class` to a `struct` type. | ||
""" | ||
}() | ||
) | ||
} |
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