mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 14:36:08 +02:00
Invert &Option
s to Option<&T>
(#10315)
Elide the reference for `Copy` type (`usize`) Use the canonical deref where possible. * `&Box` -> `&` * `&String` -> `&str` * `&PathBuf` -> `&Path` Skips the ctrl-C handler for now.
This commit is contained in:
committed by
GitHub
parent
3e14dc3eb8
commit
a14e9e0a2e
@ -54,23 +54,33 @@ impl Command for Metadata {
|
||||
} => {
|
||||
let origin = stack.get_var_with_origin(*var_id, *span)?;
|
||||
|
||||
Ok(build_metadata_record(&origin, &input.metadata(), head)
|
||||
.into_pipeline_data())
|
||||
Ok(
|
||||
build_metadata_record(&origin, input.metadata().as_deref(), head)
|
||||
.into_pipeline_data(),
|
||||
)
|
||||
}
|
||||
_ => {
|
||||
let val: Value = call.req(engine_state, stack, 0)?;
|
||||
Ok(build_metadata_record(&val, &input.metadata(), head)
|
||||
.into_pipeline_data())
|
||||
Ok(
|
||||
build_metadata_record(&val, input.metadata().as_deref(), head)
|
||||
.into_pipeline_data(),
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let val: Value = call.req(engine_state, stack, 0)?;
|
||||
Ok(build_metadata_record(&val, &input.metadata(), head).into_pipeline_data())
|
||||
Ok(
|
||||
build_metadata_record(&val, input.metadata().as_deref(), head)
|
||||
.into_pipeline_data(),
|
||||
)
|
||||
}
|
||||
}
|
||||
Some(_) => {
|
||||
let val: Value = call.req(engine_state, stack, 0)?;
|
||||
Ok(build_metadata_record(&val, &input.metadata(), head).into_pipeline_data())
|
||||
Ok(
|
||||
build_metadata_record(&val, input.metadata().as_deref(), head)
|
||||
.into_pipeline_data(),
|
||||
)
|
||||
}
|
||||
None => {
|
||||
let mut record = Record::new();
|
||||
@ -109,11 +119,7 @@ impl Command for Metadata {
|
||||
}
|
||||
}
|
||||
|
||||
fn build_metadata_record(
|
||||
arg: &Value,
|
||||
metadata: &Option<Box<PipelineMetadata>>,
|
||||
head: Span,
|
||||
) -> Value {
|
||||
fn build_metadata_record(arg: &Value, metadata: Option<&PipelineMetadata>, head: Span) -> Value {
|
||||
let mut record = Record::new();
|
||||
|
||||
let span = arg.span();
|
||||
@ -128,7 +134,7 @@ fn build_metadata_record(
|
||||
),
|
||||
);
|
||||
|
||||
if let Some(x) = metadata.as_deref() {
|
||||
if let Some(x) = metadata {
|
||||
match x {
|
||||
PipelineMetadata {
|
||||
data_source: DataSource::Ls,
|
||||
|
Reference in New Issue
Block a user