MCPcopy Create free account
hub / github.com/Stranger6667/css-inline / combine_extra_css

Function combine_extra_css

css-inline/src/main.rs:177–201  ·  view source on GitHub ↗
(
        extra_css: Option<String>,
        extra_css_files: Vec<String>,
    )

Source from the content-addressed store, hash-verified

175 }
176
177 fn combine_extra_css(
178 extra_css: Option<String>,
179 extra_css_files: Vec<String>,
180 ) -> Result<Option<String>, Box<dyn std::error::Error>> {
181 let mut buffer = extra_css.unwrap_or_default();
182
183 if !buffer.is_empty() {
184 buffer.push('\n');
185 }
186
187 for path in extra_css_files {
188 let mut file =
189 File::open(&path).map_err(|e| format!("Failed to read CSS file '{path}': {e}"))?;
190 file.read_to_string(&mut buffer)?;
191 if !buffer.is_empty() {
192 buffer.push('\n');
193 }
194 }
195
196 Ok(if buffer.is_empty() {
197 None
198 } else {
199 Some(buffer)
200 })
201 }
202
203 fn format_error(filename: Option<&str>, error: impl fmt::Display) {
204 let mut buffer = String::with_capacity(128);

Callers 1

mainFunction · 0.85

Calls 2

is_emptyMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected