Syntax aware cat
1
fork

Configure Feed

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

str

+10 -12
+10 -12
syncat/src/main.rs
··· 88 88 List, 89 89 } 90 90 91 + struct Source<'a> { 92 + language: Option<String>, 93 + source: String, 94 + path: Option<&'a Path>, 95 + } 96 + 91 97 /// The syncat instance holds globally loaded configuration to prevent loading 92 98 /// it twice. 93 99 struct Syncat { ··· 106 112 meta_style, 107 113 }) 108 114 } 109 - } 110 115 111 - struct Source<'a> { 112 - language: Option<String>, 113 - source: String, 114 - path: Option<&'a Path>, 115 - } 116 - 117 - impl Syncat { 118 - fn colorize(&self, language: Option<&String>, source: String) -> anyhow::Result<String> { 116 + fn colorize(&self, language: Option<&str>, source: String) -> anyhow::Result<String> { 119 117 let language = self 120 118 .opts 121 119 .language 122 - .as_ref() 120 + .as_deref() 123 121 .or(language) 124 122 .and_then(|language| self.lang_map.get(language)); 125 123 let Some(language) = language else { ··· 149 147 150 148 fn transform( 151 149 &self, 152 - language: Option<&String>, 150 + language: Option<&str>, 153 151 source: String, 154 152 path: Option<&Path>, 155 153 ) -> anyhow::Result<Vec<Line>> { ··· 196 194 } 197 195 }; 198 196 199 - match self.transform(language.as_ref(), source, path) { 197 + match self.transform(language.as_deref(), source, path) { 200 198 Ok(lines) => { 201 199 let lines = line_numbers(lines); 202 200 // NOTE: frame is a bit weird, idk why it needs to move in and return the lines...