diff --git a/crates/format/src/fig/map.rs b/crates/format/src/fig/map.rs index b6bb4bbe5..6109b07f2 100644 --- a/crates/format/src/fig/map.rs +++ b/crates/format/src/fig/map.rs @@ -40,80 +40,41 @@ fn side_back(s: figcraft_doc::Side) -> Side { } impl Geometry for FigGeometry { - fn route( - &self, - from: RouteEnd, - to: RouteEnd, - routing: Routing, - saved: Option<&SavedRuns>, - ) -> Option> { + fn route(&self, from: RouteEnd, to: RouteEnd, routing: Routing, saved: Option<&SavedRuns>) -> Option> { let routing = match routing { Routing::Straight => figcraft_doc::Routing::Straight, Routing::Elbow => figcraft_doc::Routing::Elbow, Routing::Curved => figcraft_doc::Routing::Curved, }; - let path = saved.map(|s| ConnectorPath::Runs { - across: s.across, - at: s.at.clone(), - }); + let path = saved.map(|s| ConnectorPath::Runs { across: s.across, at: s.at.clone() }); figcraft_doc::route_along(end(from), end(to), routing, path.as_ref()) } - fn attach( - &self, - from: RouteEnd, - to: RouteEnd, - ) -> ((Point, Option), (Point, Option)) { + fn attach(&self, from: RouteEnd, to: RouteEnd) -> ((Point, Option), (Point, Option)) { let (a, b) = (end(from), end(to)); - let ((p0, p1), (s0, s1)) = ( - figcraft_doc::attach_points(a, b), - figcraft_doc::attached_sides(a, b), - ); + let ((p0, p1), (s0, s1)) = (figcraft_doc::attach_points(a, b), figcraft_doc::attached_sides(a, b)); ((p0, s0.map(side_back)), (p1, s1.map(side_back))) } fn text_path_measurable(&self, d: &str) -> bool { let path = figcraft_doc::geom::svg_path(d).unwrap_or_default(); - measure::polylines(&path) - .and_then(|lines| lines.first().map(|line| line.length() > 1e-9)) - .unwrap_or(false) + measure::polylines(&path).and_then(|lines| lines.first().map(|line| line.length() > 1e-9)).unwrap_or(false) } } /// The REST API file JSON for message `msg`, with the warnings about what was skipped and the /// vector networks its layers name by `vectorNetworkRef` (for [`crate::rest::import_with_networks`]). -pub(super) fn to_rest( - msg: &Kv, - name: &str, - max_nodes: usize, -) -> (Value, Vec, Vec>) { +#[cfg(test)] +pub(super) fn to_rest(msg: &Kv, name: &str, max_nodes: usize) -> (Value, Vec, Vec>) { to_rest_for(msg, name, max_nodes, false) } /// Map a FigJam whiteboard's stickies as native board items when `board` is true. -pub(super) fn to_rest_for( - msg: &Kv, - name: &str, - max_nodes: usize, - board: bool, -) -> (Value, Vec, Vec>) { - let options = rest::Options { - max_nodes, - geometry: &FigGeometry, - outlined_stroke: Some(super::export::STASH), - board, - }; +pub(super) fn to_rest_for(msg: &Kv, name: &str, max_nodes: usize, board: bool) -> (Value, Vec, Vec>) { + let options = rest::Options { max_nodes, geometry: &FigGeometry, outlined_stroke: Some(super::export::STASH), board }; let mapped = rest::to_rest(msg, name, &options); // Each network passes the importer's own checks, as the JSON's `vectorNetwork` does. - let networks = mapped - .networks - .into_iter() - .map(|n| { - serde_json::to_value(n?) - .ok() - .and_then(|v| crate::rest::network(&v)) - }) - .collect(); + let networks = mapped.networks.into_iter().map(|n| serde_json::to_value(n?).ok().and_then(|v| crate::rest::network(&v))).collect(); (mapped.json, mapped.warnings, networks) } @@ -122,8 +83,5 @@ pub(super) fn adapt_warning(w: String) -> Option { if w.contains("geometry=paths") { return None; } - Some( - w.replace("the variables JSON", "the file") - .replace("the file JSON", "the file"), - ) + Some(w.replace("the variables JSON", "the file").replace("the file JSON", "the file")) }