File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 11package scala
22import compiletime .ops .boolean .*
3+ import compiletime .summonAll
34
45import language .experimental .captureChecking
56
@@ -209,6 +210,14 @@ object NamedTupleDecomposition:
209210 /** An immutable array consisting of all element values */
210211 inline def toIArray : IArray [Object ] = x.toTuple.toIArray
211212
213+ /** An immutable map consisting of all element values.
214+ * Keys are the names of the elements.
215+ */
216+ inline def toMap : collection.Map [String , Tuple .Union [V ]] =
217+ summonAll[Tuple .Map [N , ValueOf ]].toList
218+ .map(_.asInstanceOf [ValueOf [? <: String ]].value)
219+ .lazyZip(x.toList)
220+ .toMap
212221 end extension
213222
214223 /** The names of a named tuple, represented as a tuple of literal string values. */
You can’t perform that action at this time.
0 commit comments