Structure
AnyStorage
public struct AnyStorage<Item: Storable>
A struct
defining a type-erased instance of Storage
.
Relationships
Conforms To
Sequence
Storage
Initializers
init(_:)
public init<S: Storage>(_ storage: S) where S.Item == Item
Init.
Parameters
Name | Type | Description |
---|---|---|
storage | S |
Some |
Methods
makeIterator()
public func makeIterator() -> AnyIterator<Item>
Compose the iterator.
Returns
Some IteratorProtocol
.
insert(_:)
@discardableResult
public func insert(_ item: Item) throws -> (inserted: Bool, memberAfterInsert: Item)
Insert a new item.
Parameters
Name | Type | Description |
---|---|---|
item | Item |
Some |
Returns
A tuple indicating whether a previous value existed, and what this value was.
removeValue(forKey:)
@discardableResult
public func removeValue(forKey key: Item.ID) throws -> Item?
Remove the associated item, if it exists.
Parameters
Name | Type | Description |
---|---|---|
key | Item.ID |
Some |
Throws
Any Error
.
Returns
The removed Item
, if it exists.