Skip to content

Commit 935cf13

Browse files
committed
Extract table_info_or_bail()
1 parent c271ac8 commit 935cf13

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

crates/ark/src/data_explorer/r_data_explorer.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use harp::utils::r_is_object;
3535
use harp::utils::r_is_s4;
3636
use harp::utils::r_typeof;
3737
use harp::vector::formatted_vector::FormattedVector;
38+
use harp::TableInfo;
3839
use libr::*;
3940
use serde::Deserialize;
4041
use serde::Serialize;
@@ -196,8 +197,7 @@ impl RDataExplorer {
196197
let table = self.table.get().clone();
197198
let object = *table;
198199

199-
let info =
200-
harp::table_info(object).ok_or(anyhow!("Unsupported type for data viewer"))?;
200+
let info = table_info_or_bail(object)?;
201201

202202
let harp::TableInfo {
203203
kind,
@@ -262,7 +262,7 @@ impl RDataExplorer {
262262
num_cols: num_columns,
263263
},
264264
col_names: _,
265-
} = harp::table_info(object).ok_or(anyhow!("Unsupported type for data viewer"))?;
265+
} = table_info_or_bail(object)?;
266266

267267
let state = TableState {
268268
table_shape: TableShape {
@@ -284,7 +284,7 @@ impl RDataExplorer {
284284
let table = self.table.get().clone();
285285
let object = *table;
286286

287-
let info = harp::table_info(object).ok_or(anyhow!("Unsupported type for data viewer"))?;
287+
let info = table_info_or_bail(object)?;
288288

289289
let harp::TableInfo {
290290
dims:
@@ -411,6 +411,10 @@ fn display_type(x: SEXP) -> ColumnSchemaTypeDisplay {
411411
}
412412
}
413413

414+
fn table_info_or_bail(x: SEXP) -> anyhow::Result<TableInfo> {
415+
harp::table_info(x).ok_or(anyhow!("Unsupported type for data viewer"))
416+
}
417+
414418
#[harp::register]
415419
pub unsafe extern "C" fn ps_view_data_frame(x: SEXP, title: SEXP) -> anyhow::Result<SEXP> {
416420
let x = RObject::new(x);

0 commit comments

Comments
 (0)