mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 06:55:36 +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:
@ -329,7 +329,7 @@ pub fn eval_expression(
|
||||
Expr::ImportPattern(_) => Ok(Value::Nothing { span: expr.span }),
|
||||
Expr::Overlay(_) => {
|
||||
let name =
|
||||
String::from_utf8_lossy(engine_state.get_span_contents(&expr.span)).to_string();
|
||||
String::from_utf8_lossy(engine_state.get_span_contents(expr.span)).to_string();
|
||||
|
||||
Ok(Value::String {
|
||||
val: name,
|
||||
@ -1128,7 +1128,7 @@ pub fn eval_block(
|
||||
{
|
||||
let element_span = pipeline.elements[i].span();
|
||||
let element_str = String::from_utf8_lossy(
|
||||
engine_state.get_span_contents(&pipeline.elements[i].span()),
|
||||
engine_state.get_span_contents(pipeline.elements[i].span()),
|
||||
)
|
||||
.to_string();
|
||||
|
||||
|
@ -548,8 +548,7 @@ impl<'e, 's> ScopeData<'e, 's> {
|
||||
Value::String { val: key, span },
|
||||
Value::String {
|
||||
val: String::from_utf8_lossy(
|
||||
self.engine_state
|
||||
.get_span_contents(&alias.wrapped_call.span),
|
||||
self.engine_state.get_span_contents(alias.wrapped_call.span),
|
||||
)
|
||||
.to_string(),
|
||||
span,
|
||||
|
Reference in New Issue
Block a user