Remove redundant cast in tables
This commit is contained in:
parent
b78fc2e7d7
commit
bc8878da48
@ -134,14 +134,11 @@ private fun Output.writeValue(value: Value, width: Int, left: Boolean = true) {
|
|||||||
* Write rows without header to the output
|
* Write rows without header to the output
|
||||||
*/
|
*/
|
||||||
suspend fun Output.writeRows(rows: Rows<Value>) {
|
suspend fun Output.writeRows(rows: Rows<Value>) {
|
||||||
@Suppress("UNCHECKED_CAST") val header = rows.header.map {
|
val widths: List<Int> = rows.header.map {
|
||||||
if (it.type != Value::class) error("Expected Value column, but found ${it.type}") else (it as ColumnHeader<Value>)
|
|
||||||
}
|
|
||||||
val widths: List<Int> = header.map {
|
|
||||||
it.textWidth
|
it.textWidth
|
||||||
}
|
}
|
||||||
rows.rowFlow().collect { row ->
|
rows.rowFlow().collect { row ->
|
||||||
header.forEachIndexed { index, columnHeader ->
|
rows.header.forEachIndexed { index, columnHeader ->
|
||||||
writeValue(row[columnHeader] ?: Null, widths[index])
|
writeValue(row[columnHeader] ?: Null, widths[index])
|
||||||
}
|
}
|
||||||
writeUtf8String("\r\n")
|
writeUtf8String("\r\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user