[stdlib] Using map and guard let for nil handling

This commit is contained in:
codestergit
2015-12-06 04:01:33 +05:30
parent d0d038bdab
commit 6e85e69283
2 changed files with 3 additions and 5 deletions

View File

@@ -177,9 +177,8 @@ public struct EnumerateGenerator<
///
/// - Requires: No preceding call to `self.next()` has returned `nil`.
public mutating func next() -> Element? {
let b = base.next()
if b == nil { return .None }
return .Some((index: count++, element: b!))
guard let b = base.next() else { return .None }
return .Some((index: count++, element: b))
}
}