diff --git a/src/context.rs b/src/context.rs index fe7d99319..70c0485d3 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1,7 +1,6 @@ use crate::commands::{Command, UnevaluatedCallInfo}; use crate::parser::{hir, hir::syntax_shape::ExpandContext}; use crate::prelude::*; -use derive_new::new; use indexmap::IndexMap; use serde::{Deserialize, Serialize}; use std::error::Error; @@ -15,12 +14,19 @@ pub enum AnchorLocation { Source(Text), } -#[derive(Clone, new)] +#[derive(Clone)] pub struct CommandRegistry { - #[new(value = "Arc::new(Mutex::new(IndexMap::default()))")] registry: Arc>>>, } +impl CommandRegistry { + pub fn new() -> CommandRegistry { + CommandRegistry { + registry: Arc::new(Mutex::new(IndexMap::default())), + } + } +} + impl CommandRegistry { pub(crate) fn empty() -> CommandRegistry { CommandRegistry { diff --git a/src/evaluate/evaluator.rs b/src/evaluate/evaluator.rs index ceb555c33..aee48f2e8 100644 --- a/src/evaluate/evaluator.rs +++ b/src/evaluate/evaluator.rs @@ -6,18 +6,24 @@ use crate::parser::{ }; use crate::prelude::*; use crate::TaggedDictBuilder; -use derive_new::new; use indexmap::IndexMap; use log::trace; use std::fmt; -#[derive(new)] pub struct Scope { it: Tagged, - #[new(default)] vars: IndexMap>, } +impl Scope { + pub fn new(it: Tagged) -> Scope { + Scope { + it, + vars: IndexMap::new(), + } + } +} + impl fmt::Display for Scope { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_map() diff --git a/src/parser/hir/named.rs b/src/parser/hir/named.rs index 152525f0a..fcea6caa2 100644 --- a/src/parser/hir/named.rs +++ b/src/parser/hir/named.rs @@ -1,7 +1,6 @@ use crate::parser::hir::Expression; use crate::parser::Flag; use crate::prelude::*; -use derive_new::new; use indexmap::IndexMap; use log::trace; use serde::{Deserialize, Serialize}; @@ -15,12 +14,19 @@ pub enum NamedValue { Value(Expression), } -#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize, new)] +#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] pub struct NamedArguments { - #[new(default)] pub(crate) named: IndexMap, } +impl NamedArguments { + pub fn new() -> NamedArguments { + NamedArguments { + named: IndexMap::new(), + } + } +} + impl FormatDebug for NamedArguments { fn fmt_debug(&self, f: &mut DebugFormatter, source: &str) -> fmt::Result { for (name, value) in &self.named { diff --git a/src/parser/parse/token_tree_builder.rs b/src/parser/parse/token_tree_builder.rs index 7146a3c20..00b7581f8 100644 --- a/src/parser/parse/token_tree_builder.rs +++ b/src/parser/parse/token_tree_builder.rs @@ -6,17 +6,21 @@ use crate::parser::parse::pipeline::{Pipeline, PipelineElement}; use crate::parser::parse::token_tree::{DelimitedNode, Delimiter, TokenNode}; use crate::parser::parse::tokens::{RawNumber, RawToken}; use crate::parser::CallNode; -use derive_new::new; -#[derive(new)] pub struct TokenTreeBuilder { - #[new(default)] pos: usize, - - #[new(default)] output: String, } +impl TokenTreeBuilder { + pub fn new() -> TokenTreeBuilder { + TokenTreeBuilder { + pos: 0, + output: String::new(), + } + } +} + pub type CurriedToken = Box TokenNode + 'static>; pub type CurriedCall = Box Spanned + 'static>; diff --git a/src/parser/registry.rs b/src/parser/registry.rs index ff0a98ae8..11f9d6baa 100644 --- a/src/parser/registry.rs +++ b/src/parser/registry.rs @@ -60,22 +60,28 @@ impl PositionalType { type Description = String; -#[derive(Debug, Serialize, Deserialize, Clone, new)] +#[derive(Debug, Serialize, Deserialize, Clone)] pub struct Signature { pub name: String, - #[new(default)] pub usage: String, - #[new(default)] pub positional: Vec<(PositionalType, Description)>, - #[new(value = "None")] pub rest_positional: Option<(SyntaxShape, Description)>, - #[new(default)] pub named: IndexMap, - #[new(value = "false")] pub is_filter: bool, } impl Signature { + pub fn new(name: String) -> Signature { + Signature { + name, + usage: String::new(), + positional: vec![], + rest_positional: None, + named: IndexMap::new(), + is_filter: false, + } + } + pub fn build(name: impl Into) -> Signature { Signature::new(name.into()) }