Check that the `idx`th column of the row type stored by `row_ref` is compatible with `Self`, and read the value of that column from `row_ref`.
(row_ref: RowRef<'_>, idx: usize)
| 139 | /// Check that the `idx`th column of the row type stored by `row_ref` is compatible with `Self`, |
| 140 | /// and read the value of that column from `row_ref`. |
| 141 | fn read_column(row_ref: RowRef<'_>, idx: usize) -> Result<Self, TypeError> { |
| 142 | let layout = row_ref.row_layout().product(); |
| 143 | |
| 144 | // Look up the `ProductTypeElementLayout` of the requested column, |
| 145 | // or return an error on an out-of-bounds index. |
| 146 | let col = layout.elements.get(idx).ok_or_else(|| TypeError::IndexOutOfBounds { |
| 147 | desired: idx, |
| 148 | found: layout.product_type(), |
| 149 | })?; |
| 150 | |
| 151 | // Check that the requested column is of the expected type. |
| 152 | if !Self::is_compatible_type(&col.ty) { |
| 153 | return Err(TypeError::WrongType { |
| 154 | desired: std::any::type_name::<Self>(), |
| 155 | found: col.ty.algebraic_type(), |
| 156 | }); |
| 157 | } |
| 158 | |
| 159 | Ok(unsafe { |
| 160 | // SAFETY: |
| 161 | // - We trust that the `row_ref.table` knows its own layout, |
| 162 | // and we've derived our type and layout info from it, |
| 163 | // so they are correct. |
| 164 | // - We trust `Self::is_compatible_type`, and it returned `true`, |
| 165 | // so the column must be of appropriate type. |
| 166 | Self::unchecked_read_column(row_ref, col) |
| 167 | }) |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | unsafe impl ReadColumn for bool { |
nothing calls this directly
no test coverage detected