mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Replace &Span
with Span
since Span
is Copy
(#9770)
# Description `Span` is `Copy`, so we probably should not be passing references of `Span` around. This PR replaces all instances of `&Span` with `Span`, copying spans where necessary. # User-Facing Changes This alters some public functions to take `Span` instead of `&Span` as input. Namely, `EngineState::get_span_contents`, `nu_protocol::extract_value`, a bunch of the math commands, and `Gstat::gstat`.
This commit is contained in:
@ -204,10 +204,10 @@ impl From<DirInfo> for Value {
|
||||
});
|
||||
|
||||
cols.push("directories".into());
|
||||
vals.push(value_from_vec(d.dirs, &d.tag));
|
||||
vals.push(value_from_vec(d.dirs, d.tag));
|
||||
|
||||
cols.push("files".into());
|
||||
vals.push(value_from_vec(d.files, &d.tag));
|
||||
vals.push(value_from_vec(d.files, d.tag));
|
||||
|
||||
// if !d.errors.is_empty() {
|
||||
// let v = d
|
||||
@ -271,17 +271,17 @@ impl From<FileInfo> for Value {
|
||||
}
|
||||
}
|
||||
|
||||
fn value_from_vec<V>(vec: Vec<V>, tag: &Span) -> Value
|
||||
fn value_from_vec<V>(vec: Vec<V>, tag: Span) -> Value
|
||||
where
|
||||
V: Into<Value>,
|
||||
{
|
||||
if vec.is_empty() {
|
||||
Value::nothing(*tag)
|
||||
Value::nothing(tag)
|
||||
} else {
|
||||
let values = vec.into_iter().map(Into::into).collect::<Vec<Value>>();
|
||||
Value::List {
|
||||
vals: values,
|
||||
span: *tag,
|
||||
span: tag,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user