Skip to content

[SR-4165] Add an UpToOne Collection #46748

@dabrahams

Description

@dabrahams
Previous ID SR-4165
Radar None
Original Reporter @dabrahams
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee None
Priority Medium

md5: f39656b2b2aeb1cf4e0042dba951599f

Issue Description:

If we had UpToOne<T> as an adapter over T? we could stop generating such a messy type from

(0..<10).lazy.flatMap { $0 < 5 ? nil : $0 }

It's currently LazyMapBidirectionalCollection<LazyFilterBidirectionalCollection<LazyMapBidirectionalCollection<(CountableRange<Int>), Int?>>, Int>

but could be

LazyCollection<FlattenBidirectionalCollection<LazyMapBidirectionalCollection<(CountableRange<Int>), UpToOne<Int>>>>

but more importantly, it would allow us to supply a single generic typealias for the result of calling lazy flatMaps (on bidirectional collections today; on all collections once we have conditional conformance).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.standard libraryArea: Standard library umbrella

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions