Skip to content

OrderedDictionary updateValue autoclosure for insertion index #312

Open
@andrews05

Description

@andrews05

I'm using the following OrderedDictionary function:

  public mutating func updateValue<R>(
    forKey key: Key,
    insertingDefault defaultValue: @autoclosure () -> Value,
    at index: Int,
    with body: (inout Value) throws -> R
  )

The defaultValue is an autoclosure, which is great, but it would be helpful if the index was also an autoclosure to prevent a possibly expensive index calculation if the key already exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions