Tholp's bespoke website generator
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

make for_each_arg not suck as hard

Tholp1 d62d2639 f5031460

+18 -5
+3 -3
src/macros/simple_blocks.rs
··· 5 5 use crate::{ 6 6 console::error_skid, 7 7 projectparse::{FileIndexing, ProjectContext}, 8 - stringtools::{find_pattern, split_to_tokens}, 8 + stringtools::{find_pattern, split_to_tokens, TokenTools, WhitespaceChecks}, 9 9 types::{InputFile, Token}, 10 10 }; 11 11 ··· 102 102 let (start, len) = found_pattern.unwrap(); 103 103 let replacement = split_to_tokens(arg.clone(), origin_index); 104 104 arg_output.splice(start..start + len, replacement); 105 - found_pattern = find_pattern(&output, format!("[[..{}]]", replacement_index + 1)); 105 + found_pattern = find_pattern(&arg_output, format!("[[..{}]]", replacement_index + 1)); 106 106 println!("{}", replacement_index + 1); 107 107 } 108 108 ··· 110 110 replacement_index += 1; 111 111 if replacement_index == replacement_count { 112 112 replacement_index = 0; 113 - output.append(&mut arg_output); 113 + output.append(&mut arg_output.trim_whitespace().into()); 114 114 arg_output = block.clone(); 115 115 println!("push"); 116 116 }
+4 -1
src/macros/template.rs
··· 128 128 let (start, len) = found_trailing_pattern.unwrap(); 129 129 let mut replacement = Vec::new(); 130 130 for arg in &args[self.args.len()..] { 131 - replacement.append(&mut split_to_tokens("\"".to_string() + arg + "\" ".into(), origin_index)); 131 + replacement.append(&mut split_to_tokens( 132 + "\"".to_string() + arg + "\" ".into(), 133 + origin_index, 134 + )); 132 135 } 133 136 output.splice(start..start + len, replacement); 134 137 found_trailing_pattern = find_pattern(&output, "[[\"..\"]]".into());
+1 -1
src/main.rs
··· 22 22 use types::{InputFile, Macro, Token}; 23 23 24 24 static DELIMITERS: &'static [char] = &[ 25 - ' ', '\n', '\t', '(', ')', '{', '}', '[', ']', '\\', '\'', '\"', ';', 25 + ' ', '\n', '\t', '(', ')', '{', '}', '[', ']', '<', '>', '\\', '\'', '\"', ';', 26 26 ]; 27 27 28 28 fn main() {
+10
src/stringtools.rs
··· 309 309 return false; 310 310 } 311 311 } 312 + 313 + pub trait TokenTools { 314 + fn trim_whitespace(&mut self) -> &[Token]; 315 + } 316 + 317 + impl TokenTools for Vec<Token> { 318 + fn trim_whitespace(&mut self) -> &[Token] { 319 + return trim_whitespace_tokens(&self[..]); 320 + } 321 + }