aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Igne <git@federicoigne.com>2022-04-27 22:22:28 +0100
committerFederico Igne <git@federicoigne.com>2022-05-27 00:46:28 +0100
commitb1be339479acba05b98d3ae1b3f20d3e8fcc0ca4 (patch)
treec9854022b37633c3df8164fc4e6333677b29eb25
parent394621b3a2290e363a60b372e07ad19c47105ff1 (diff)
downloadpangler-b1be339479acba05b98d3ae1b3f20d3e8fcc0ca4.tar.gz
pangler-b1be339479acba05b98d3ae1b3f20d3e8fcc0ca4.zip
feat: concat codeblocks with same ID by default
-rw-r--r--src/main.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index a8b8198..3890ae9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -96,7 +96,15 @@ fn main() -> Result<()> {
96 * NOTE: we are always "borrowing" the snippets of code with `Cow`, i.e., it 96 * NOTE: we are always "borrowing" the snippets of code with `Cow`, i.e., it
97 * will always be a `Cow::Borrowed` value, until we process the string 97 * will always be a `Cow::Borrowed` value, until we process the string
98 * substituting macros. */ 98 * substituting macros. */
99 blocks.insert(key, Cow::from(code)); 99 //blocks.insert(key, Cow::from(code));
100 blocks.entry(key)
101 .and_modify(|s| {
102 let mut concat = s.to_string();
103 concat.push_str("\n");
104 concat.push_str(code);
105 *s = Cow::from(concat);
106 })
107 .or_insert(Cow::from(code));
100 } else { 108 } else {
101 // println!("The following code has no ID:"); 109 // println!("The following code has no ID:");
102 // code.lines().for_each(|l| println!(" {}", l)); 110 // code.lines().for_each(|l| println!(" {}", l));