From 85d47c299eb89571aad848c37a26994e71ec33de Mon Sep 17 00:00:00 2001 From: Han Junghyuk <136320007+hanjunghyuk@users.noreply.github.com> Date: Fri, 7 Jul 2023 10:17:55 +0900 Subject: [PATCH] Fix `explore` crashes on {} (#9623) # Description Fixes: #8479 Co-authored-by: Jan9103 <55753387+Jan9103@users.noreply.github.com> # User-Facing Changes # Tests + Formatting # After Submitting --------- Co-authored-by: Jan9103 <55753387+Jan9103@users.noreply.github.com> --- crates/nu-explore/src/nu_common/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/nu-explore/src/nu_common/mod.rs b/crates/nu-explore/src/nu_common/mod.rs index 7fdbb6d26..337e767f6 100644 --- a/crates/nu-explore/src/nu_common/mod.rs +++ b/crates/nu-explore/src/nu_common/mod.rs @@ -22,9 +22,10 @@ pub use table::try_build_table; pub use value::{collect_input, collect_pipeline, create_map, map_into_value, nu_str}; pub fn has_simple_value(data: &[Vec]) -> Option<&Value> { - let has_single_value = data.len() == 1 && data[0].len() == 1; - let is_complex_type = matches!(&data[0][0], Value::List { .. } | Value::Record { .. }); - if has_single_value && !is_complex_type { + if data.len() == 1 + && data[0].len() == 1 + && !matches!(&data[0][0], Value::List { .. } | Value::Record { .. }) + { Some(&data[0][0]) } else { None