mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 03:42:17 +00:00
remove itertools dependency
This commit is contained in:
parent
d8441704d6
commit
107f4d3f6c
4 changed files with 44 additions and 9 deletions
|
@ -14,4 +14,3 @@ serde = { version = "1.0.144", features = ["derive"] }
|
|||
palette = "0.6.1"
|
||||
snafu = { version = "0.7.1", features = ["backtraces"] }
|
||||
bumpalo = { version = "3.11.0", features = ["collections"] }
|
||||
itertools = "0.10.5"
|
||||
|
|
|
@ -15,7 +15,6 @@ use crate::{
|
|||
syntax_highlight::HighlightStyle,
|
||||
};
|
||||
|
||||
use itertools::Itertools;
|
||||
use roc_ast::{
|
||||
ast_error::ASTResult,
|
||||
lang::{
|
||||
|
@ -409,10 +408,10 @@ pub fn expr2_to_markup<'a>(
|
|||
})
|
||||
.collect::<ModuleResult<Vec<&str>>>()?;
|
||||
|
||||
let arg_mark_nodes = arg_names
|
||||
let arg_mark_nodes: Vec<_> = arg_names
|
||||
.iter()
|
||||
.map(|arg_name| new_arg_name_mn(arg_name.to_string()))
|
||||
.collect_vec();
|
||||
.collect();
|
||||
|
||||
let args_with_commas: Vec<MarkupNode> = join_mark_nodes_commas(arg_mark_nodes);
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ use super::{
|
|||
use crate::markup_error::{
|
||||
ExpectedTextNodeSnafu, NestedNodeMissingChildSnafu, NestedNodeRequiredSnafu,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use roc_ast::{
|
||||
lang::{core::ast::ASTNodeId, env::Env},
|
||||
mem_pool::pool_str::PoolStr,
|
||||
|
@ -448,9 +447,9 @@ pub fn join_mark_nodes_spaces(
|
|||
.collect();
|
||||
|
||||
if with_prepend {
|
||||
join_nodes.into_iter().interleave(mark_nodes_ids).collect()
|
||||
interleave(join_nodes.into_iter(), mark_nodes_ids)
|
||||
} else {
|
||||
mark_nodes_ids.into_iter().interleave(join_nodes).collect()
|
||||
interleave(mark_nodes_ids, join_nodes.into_iter())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -460,7 +459,7 @@ pub fn join_mark_nodes_commas(mark_nodes: Vec<MarkupNode>) -> Vec<MarkupNode> {
|
|||
.map(|_| new_comma_mn())
|
||||
.collect();
|
||||
|
||||
mark_nodes.into_iter().interleave(join_nodes).collect()
|
||||
interleave(mark_nodes.into_iter(), join_nodes)
|
||||
}
|
||||
|
||||
pub fn mark_nodes_to_string(markup_node_ids: &[MarkNodeId], mark_node_pool: &SlowPool) -> String {
|
||||
|
@ -493,3 +492,42 @@ pub fn node_to_string_w_children(
|
|||
str_buffer.push_str(&node_content_str);
|
||||
}
|
||||
}
|
||||
|
||||
fn interleave<I, J>(i: I, j: J) -> Vec<I::Item>
|
||||
where
|
||||
I: IntoIterator,
|
||||
J: IntoIterator<Item = I::Item>,
|
||||
{
|
||||
let mut output = Vec::new();
|
||||
|
||||
let mut flag = false;
|
||||
|
||||
let mut i = i.into_iter();
|
||||
let mut j = j.into_iter();
|
||||
|
||||
loop {
|
||||
flag = !flag;
|
||||
|
||||
if flag {
|
||||
match i.next() {
|
||||
None => {
|
||||
output.extend(j);
|
||||
break output;
|
||||
}
|
||||
Some(v) => {
|
||||
output.push(v);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
match j.next() {
|
||||
None => {
|
||||
output.extend(i);
|
||||
break output;
|
||||
}
|
||||
Some(v) => {
|
||||
output.push(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue