mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-24 01:38:26 +00:00
Replace if let with guard let (#1466)
Summary: ## Changes in this pull request ### Checklist - [x] All tests pass. Demo project builds and runs. - [x] I added tests, an experiment, or detailed why my change isn't tested. - [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes. - [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md) Pull Request resolved: https://github.com/Instagram/IGListKit/pull/1466 Reviewed By: bdotdub Differential Revision: D24235336 Pulled By: lorixx fbshipit-source-id: bfc5fab26ae28ff9306d1b889b82b49c6ae2a636
This commit is contained in:
parent
bee04ca961
commit
b948982674
2 changed files with 7 additions and 10 deletions
|
|
@ -33,11 +33,10 @@ public extension ListIdentifiable {
|
|||
|
||||
// TODO(natesm): Should this be a public API? It is for now.
|
||||
init?(diffable: Any) {
|
||||
if let value = (diffable as? ListDiffableValueBox<Self>)?.value {
|
||||
self = value
|
||||
} else {
|
||||
guard let value = (diffable as? ListDiffableValueBox<Self>)?.value else {
|
||||
return nil
|
||||
}
|
||||
self = value
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -63,10 +62,9 @@ private final class ListDiffableValueBox<Value: ListIdentifiable>: NSObject, Lis
|
|||
}
|
||||
|
||||
func isEqual(toDiffableObject object: ListDiffable?) -> Bool {
|
||||
if let other = object as? ListDiffableValueBox<Value> {
|
||||
return value == other.value
|
||||
} else {
|
||||
guard let other = object as? ListDiffableValueBox<Value> else {
|
||||
return false
|
||||
}
|
||||
return value == other.value
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,12 +23,11 @@ open class ListValueSectionController<Value: ListIdentifiable>: ListSectionContr
|
|||
/// Subclasses of `ListValueSectionController` may not override `didUpdate(to:)` for objects.
|
||||
/// Instead, they must use the overload for generic values.
|
||||
public final override func didUpdate(to object: Any) {
|
||||
if let value = Value(diffable: object) {
|
||||
self.value = value
|
||||
didUpdate(to: value)
|
||||
} else {
|
||||
guard let value = Value(diffable: object) else {
|
||||
fatalError("Expected object for value section controller to be a boxed \(Value.self), but it was \(object)")
|
||||
}
|
||||
self.value = value
|
||||
didUpdate(to: value)
|
||||
}
|
||||
|
||||
/// Updates the section controller to a new value.
|
||||
|
|
|
|||
Loading…
Reference in a new issue