Move from using a Block to an Arc'd Block (#3289)

This commit is contained in:
Jonathan Turner
2021-04-09 20:12:25 +12:00
committed by GitHub
parent ac070ae942
commit b791d1ab0d
11 changed files with 81 additions and 54 deletions

View File

@ -233,7 +233,11 @@ pub fn cli(context: EvaluationContext, options: Options) -> Result<(), Box<dyn E
context.scope.enter_scope();
let (mut prompt_block, err) = nu_parser::parse(&prompt_line, 0, &context.scope);
prompt_block.set_redirect(ExternalRedirection::Stdout);
if let Some(block) =
std::sync::Arc::<nu_protocol::hir::Block>::get_mut(&mut prompt_block)
{
block.set_redirect(ExternalRedirection::Stdout);
}
if err.is_some() {
context.scope.exit_scope();

View File

@ -254,6 +254,8 @@ pub fn completion_location(line: &str, block: &Block, pos: usize) -> Vec<Complet
#[cfg(test)]
mod tests {
use std::sync::Arc;
use super::*;
use nu_parser::{classify_block, lex, parse_block, ParserScope};
@ -285,9 +287,9 @@ mod tests {
todo!()
}
fn add_definition(&self, _block: Block) {}
fn add_definition(&self, _block: Arc<Block>) {}
fn get_definitions(&self) -> Vec<Block> {
fn get_definitions(&self) -> Vec<Arc<Block>> {
vec![]
}