mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 22:17:49 +02:00
Reuse Closure
type in Value::Closure
(#10894)
# Description Reuses the existing `Closure` type in `Value::Closure`. This will help with the span refactoring for `Value`. Additionally, this allows us to more easily box or unbox the `Closure` case should we chose to do so in the future. # User-Facing Changes Breaking API change for `nu_protocol`.
This commit is contained in:
@ -57,15 +57,11 @@ impl<'a> StyleComputer<'a> {
|
||||
Some(ComputableStyle::Closure(v)) => {
|
||||
let span = v.span();
|
||||
match v {
|
||||
Value::Closure {
|
||||
val: block_id,
|
||||
captures,
|
||||
..
|
||||
} => {
|
||||
let block = self.engine_state.get_block(*block_id).clone();
|
||||
Value::Closure { val, .. } => {
|
||||
let block = self.engine_state.get_block(val.block_id).clone();
|
||||
// Because captures_to_stack() clones, we don't need to use with_env() here
|
||||
// (contrast with_env() usage in `each` or `do`).
|
||||
let mut stack = self.stack.captures_to_stack(captures);
|
||||
let mut stack = self.stack.captures_to_stack(&val.captures);
|
||||
|
||||
// Support 1-argument blocks as well as 0-argument blocks.
|
||||
if let Some(var) = block.signature.get_positional(0) {
|
||||
|
Reference in New Issue
Block a user