Merge branch 'main' of https://github.com/jonathandturner/engine-q into similar-name

This commit is contained in:
Fernando Herrera
2021-09-04 09:10:38 +01:00
9 changed files with 70 additions and 40 deletions

View File

@ -119,6 +119,7 @@ impl EngineState {
.expect("internal error: missing variable")
}
#[allow(clippy::borrowed_box)]
pub fn get_decl(&self, decl_id: DeclId) -> &Box<dyn Command> {
self.decls
.get(decl_id)
@ -460,6 +461,7 @@ impl<'a> StateWorkingSet<'a> {
}
}
#[allow(clippy::borrowed_box)]
pub fn get_decl(&self, decl_id: DeclId) -> &Box<dyn Command> {
let num_permanent_decls = self.permanent_state.num_decls();
if decl_id < num_permanent_decls {

View File

@ -249,9 +249,8 @@ impl Signature {
pub fn num_positionals_after(&self, idx: usize) -> usize {
let mut total = 0;
let mut curr = 0;
for positional in &self.required_positional {
for (curr, positional) in self.required_positional.iter().enumerate() {
match positional.shape {
SyntaxShape::Keyword(..) => {
// Keywords have a required argument, so account for that
@ -265,7 +264,6 @@ impl Signature {
}
}
}
curr += 1;
}
total
}

View File

@ -9,13 +9,11 @@ pub struct ValueStream(pub Rc<RefCell<dyn Iterator<Item = Value>>>);
impl ValueStream {
pub fn into_string(self) -> String {
let val: Vec<Value> = self.collect();
format!(
"[{}]",
val.into_iter()
.map(|x| x.into_string())
self.map(|x| x.into_string())
.collect::<Vec<String>>()
.join(", ".into())
.join(", ")
)
}
@ -59,23 +57,21 @@ pub struct RowStream(Rc<RefCell<dyn Iterator<Item = Vec<Value>>>>);
impl RowStream {
pub fn into_string(self, headers: Vec<String>) -> String {
let val: Vec<Vec<Value>> = self.collect();
format!(
"[{}]\n[{}]",
headers
.iter()
.map(|x| x.to_string())
.collect::<Vec<String>>()
.join(", ".into()),
val.into_iter()
.map(|x| {
x.into_iter()
.map(|x| x.into_string())
.collect::<Vec<String>>()
.join(", ".into())
})
.collect::<Vec<String>>()
.join("\n")
.join(", "),
self.map(|x| {
x.into_iter()
.map(|x| x.into_string())
.collect::<Vec<String>>()
.join(", ")
})
.collect::<Vec<String>>()
.join("\n")
)
}
}