this repo has no description
1
fork

Configure Feed

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

chore: fix all clippy warnings; remove dead frag_end variable

- tala-format: collapse 4 nested if chains into && let chains
- tala-typst: loop+match -> while let; suppress too_many_arguments on
frame walkers (context struct adds indirection without clarity gain);
remove dead frag_end variable and its let _ = frag_end suppress hack
- tala: &PathBuf -> &Path on persist_dir and render_preview; add Path
import; 4 redundant || Vec::new() closures -> Vec::new fn pointers

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

+36 -44
+22 -23
crates/tala-format/src/lib.rs
··· 60 60 // ── Tree walking ────────────────────────────────────────────────────────────── 61 61 62 62 fn walk(node: &LinkedNode<'_>, out: &mut Vec<CardEntry>) { 63 - if node.kind() == SyntaxKind::FuncCall { 64 - if let Some(entry) = try_parse_card(node) { 65 - out.push(entry); 66 - // Don't recurse into a card we just consumed. 67 - return; 68 - } 63 + if node.kind() == SyntaxKind::FuncCall 64 + && let Some(entry) = try_parse_card(node) 65 + { 66 + out.push(entry); 67 + // Don't recurse into a card we just consumed. 68 + return; 69 69 } 70 70 for child in node.children() { 71 71 walk(&child, out); ··· 118 118 match child.kind() { 119 119 SyntaxKind::Named => { 120 120 // Check if this is `tags: (...)` — handle separately. 121 - if let Some(key) = named_key(&child) { 122 - if key == "tags" { 123 - tags = parse_named_tags(&child); 124 - continue; 125 - } 121 + if let Some(key) = named_key(&child) 122 + && key == "tags" 123 + { 124 + tags = parse_named_tags(&child); 125 + continue; 126 126 } 127 127 if let Some((k, v)) = parse_named_str(&child) { 128 128 named.insert(k, v); ··· 238 238 // ── Blank extraction ────────────────────────────────────────────────────────── 239 239 240 240 fn find_blanks(node: &LinkedNode<'_>, out: &mut Vec<BlankEntry>) { 241 - if node.kind() == SyntaxKind::FuncCall { 242 - if let Some(name) = func_ident(node) { 243 - if name == "blank" { 244 - if let Some(content_span) = blank_content_span(node) { 245 - out.push(BlankEntry { 246 - index: out.len(), 247 - span: node.range(), 248 - content_span, 249 - }); 250 - } 251 - return; 252 - } 241 + if node.kind() == SyntaxKind::FuncCall 242 + && let Some(name) = func_ident(node) 243 + && name == "blank" 244 + { 245 + if let Some(content_span) = blank_content_span(node) { 246 + out.push(BlankEntry { 247 + index: out.len(), 248 + span: node.range(), 249 + content_span, 250 + }); 253 251 } 252 + return; 254 253 } 255 254 for child in node.children() { 256 255 find_blanks(&child, out);
+6 -13
crates/tala-typst/src/lib.rs
··· 132 132 boxes.into_iter().map(|b| b.unwrap_or([0.0, 0.0, 0.0, 0.0])).collect() 133 133 } 134 134 135 + #[allow(clippy::too_many_arguments)] 135 136 fn walk_frame_for_shapes( 136 137 frame: &typst::layout::Frame, 137 138 source: &Source, ··· 155 156 let Some(sr) = source.range(*span) else { continue }; 156 157 if sr.end <= preamble_offset { continue; } 157 158 let frag_start = sr.start.saturating_sub(preamble_offset); 158 - let frag_end = sr.end - preamble_offset; 159 159 for (i, blank_span) in blank_spans.iter().enumerate() { 160 160 // Span-start-within check: catches math shapes whose node spans 161 161 // the whole expression (may extend past the blank boundary). ··· 165 165 let py = (ay + bb.min.y.to_pt() as f32) * scale; 166 166 let pw = (bb.max.x - bb.min.x).to_pt() as f32 * scale; 167 167 let ph = (bb.max.y - bb.min.y).to_pt() as f32 * scale; 168 - // Only extend the x-span (width); lines have ph=0 so vertical 169 - // extent is preserved from the text glyph heights. 170 - let _ = frag_end; // suppress warning 171 168 let shape_rect = [px, py, pw, ph]; 172 169 if shape_rect[2] > 0.0 { 173 170 boxes[i] = Some(boxes[i].map_or(shape_rect, |b| merge_rect(b, shape_rect))); ··· 225 222 map 226 223 } 227 224 225 + #[allow(clippy::too_many_arguments)] 228 226 fn walk_frame_for_glyphs( 229 227 frame: &typst::layout::Frame, 230 228 source: &Source, ··· 448 446 for data in typst_assets::fonts() { 449 447 let bytes = Bytes::new(data); 450 448 let mut index = 0u32; 451 - loop { 452 - match Font::new(bytes.clone(), index) { 453 - Some(font) => { 454 - book.push(font.info().clone()); 455 - fonts.push(font); 456 - index += 1; 457 - } 458 - None => break, 459 - } 449 + while let Some(font) = Font::new(bytes.clone(), index) { 450 + book.push(font.info().clone()); 451 + fonts.push(font); 452 + index += 1; 460 453 } 461 454 } 462 455
+8 -8
crates/tala/src/main.rs
··· 1 - use std::path::PathBuf; 1 + use std::path::{Path, PathBuf}; 2 2 use std::time::Duration; 3 3 4 4 use base64::Engine as _; ··· 21 21 if p.is_dir() { Some(p) } else { None } 22 22 } 23 23 24 - fn persist_dir(path: &PathBuf) { 24 + fn persist_dir(path: &Path) { 25 25 if let Some(f) = config_dir_file() { 26 26 if let Some(parent) = f.parent() { 27 27 let _ = std::fs::create_dir_all(parent); ··· 249 249 }); 250 250 251 251 // Blank rects, glyph map, and math spans synced from latest preview (needed in event closures). 252 - let mut blank_rects_sig = use_signal(|| Vec::<[f64; 4]>::new()); 252 + let mut blank_rects_sig = use_signal(Vec::<[f64; 4]>::new); 253 253 let mut glyph_map_sig = 254 - use_signal(|| Vec::<([f64; 4], std::ops::Range<usize>, bool)>::new()); 255 - let mut math_spans_sig = use_signal(|| Vec::<std::ops::Range<usize>>::new()); 254 + use_signal(Vec::<([f64; 4], std::ops::Range<usize>, bool)>::new); 255 + let mut math_spans_sig = use_signal(Vec::<std::ops::Range<usize>>::new); 256 256 use_effect(move || { 257 257 if let Some(Ok(data)) = &*preview.read() { 258 258 blank_rects_sig.set(data.blank_rects.clone()); ··· 266 266 let mut drag_start = use_signal(|| Option::<(f64, f64)>::None); 267 267 let mut drag_current = use_signal(|| Option::<(f64, f64)>::None); 268 268 // Blue error boxes: drawn boxes that didn't map to insertable text. 269 - let mut drawn_boxes = use_signal(|| Vec::<[f64; 4]>::new()); 269 + let mut drawn_boxes = use_signal(Vec::<[f64; 4]>::new); 270 270 // Draw-capture div dims + zoom: [offsetWidth, offsetHeight, cssZoom]. 271 271 let cap_dims = use_signal(|| [1.0f64, 1.0, 1.0]); 272 272 // Insertion error shown near the toolbar. ··· 759 759 } 760 760 } 761 761 762 - fn render_preview(source: &str, dir: &PathBuf) -> Result<PreviewData, String> { 763 - let deck_dir = dir.clone(); 762 + fn render_preview(source: &str, dir: &Path) -> Result<PreviewData, String> { 763 + let deck_dir = dir.to_path_buf(); 764 764 765 765 // Collect content_spans of all blanks in document order. 766 766 let cards = tala_format::parse_cards(source);