-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OrderedDictionary] modifyValue → updateValue (#91)
* [OrderedDictionary] modifyValue → updateValue * Update CMakeLists.txt
- Loading branch information
Showing
6 changed files
with
60 additions
and
22 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
37 changes: 37 additions & 0 deletions
37
Sources/OrderedCollections/OrderedDictionary/OrderedDictionary+Deprecations.swift
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,37 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift Collections open source project | ||
// | ||
// Copyright (c) 2021 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
extension OrderedDictionary { | ||
@available(*, deprecated, renamed: "updateValue(forKey:default:with:)") | ||
@inlinable | ||
public mutating func modifyValue<R>( | ||
forKey key: Key, | ||
default defaultValue: @autoclosure () -> Value, | ||
_ body: (inout Value) throws -> R | ||
) rethrows -> R { | ||
try self.updateValue(forKey: key, default: defaultValue(), with: body) | ||
} | ||
|
||
@available(*, deprecated, renamed: "updateValue(forKey:insertingDefault:at:with:)") | ||
@inlinable | ||
public mutating func modifyValue<R>( | ||
forKey key: Key, | ||
insertingDefault defaultValue: @autoclosure () -> Value, | ||
at index: Int, | ||
_ body: (inout Value) throws -> R | ||
) rethrows -> R { | ||
try self.updateValue( | ||
forKey: key, | ||
insertingDefault: defaultValue(), | ||
at: index, | ||
with: body) | ||
} | ||
} |
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