Fix clippy and rustdoc errors in automation, draw, imaging, svg, ui-patterns and ui-widgets

This commit is contained in:
aiongg
2026-11-16 15:40:46 +00:00
parent 5e812bbeb4
commit 2103be6de1
14 changed files with 37 additions and 26 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ use super::model::Action;
///
/// A file PhotoCraft wrote with its folder occurrences (`set_rows`, and per action `set_slot`,
/// `action_id`, `legacy_shortcut_owner`) loads too: those fields are read into
/// [`FileOccurrences`] and [`ActionList::merge_file`](super::ActionList::merge_file) turns them
/// `FileOccurrences` and [`ActionList::merge_file`](super::ActionList::merge_file) turns them
/// into unique set and action names. Names are the list's only identity, so they are never
/// written back.
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
+2 -2
View File
@@ -108,7 +108,7 @@ impl<'a> AgentsPage<'a> {
let mut next = None;
let mut field = Field::new(words.control_port.clone()).id_salt("port");
if mcp_flag {
field = field.help(Help::Text(words.port_hint.clone().into()));
field = field.help(Help::Text(words.port_hint.clone()));
}
field.show(ui, |ui, _| {
let number = NumberField::new(words.control_port.clone(), Bind::given(Some(port as f64)))
@@ -140,7 +140,7 @@ impl<'a> AgentsPage<'a> {
.map(|choice| {
let label: Label = match choice {
WhenAppClosed::Launch => words.launch.fill(&[("app", app)]).into(),
WhenAppClosed::Headless => words.headless.clone().into(),
WhenAppClosed::Headless => words.headless.clone(),
WhenAppClosed::Error => words.ask.fill(&[("app", app)]).into(),
};
Entry::new(choice, label)
+2 -2
View File
@@ -184,7 +184,7 @@ impl CropKept {
/// drawn one.
/// - Dismissal ([`dismiss`](Self::dismiss)): after Discard or an accepted crop the default frame
/// is still made but stays hidden until the next press, ratio change or size change
/// ([`show`](Self::show)), for that document and size only.
/// ([`show_frame`](Self::show_frame)), for that document and size only.
/// - [`CropTool`](super::CropTool) is the one writer: the session has no edit type of its own.
#[derive(Clone, Debug, Default)]
pub struct CropSession {
@@ -464,7 +464,7 @@ impl CropSession {
}
/// Discard or an accepted crop: the session is cleared and the document's default frame stays
/// hidden until [`show`](Self::show). The next [`ensure_frame`](Self::ensure_frame) still makes
/// hidden until [`show_frame`](Self::show_frame). The next [`ensure_frame`](Self::ensure_frame) still makes
/// the frame, so the hidden overlay has one to show.
pub fn dismiss(&mut self) {
let made_for = self.frame_for;
+1 -1
View File
@@ -109,7 +109,7 @@ pub(super) fn ruler_cursor(precise: bool, protractor: bool) -> Cursor {
/// Shift 10, Delete and Backspace clear the line.
/// - It paints a cross at each point, in the line's look; the app shows the line and the arm with `StraightLinePreview`
/// ([`RulerPass::show_line`](super::RulerPass::show_line)).
/// - [Read only](Self::read_only), it paints the crosses at rest and takes no press, key or focus: the ruler drawn
/// - [Read only](craft_ui::contract::Props::read_only), it paints the crosses at rest and takes no press, key or focus: the ruler drawn
/// under the other tools ([`show_ruler`](super::show_ruler)).
/// - **AccessKit:** the group's value reads "Length L, angle A°" in the ruler's units; each point is named and valued
/// "x, y" in the ruler's units.
+1 -3
View File
@@ -276,9 +276,7 @@ fn the_gear_enables_only_the_chosen_sizes_and_escape_keeps_the_pick() {
#[trial]
fn a_fixed_size_typed_past_its_range_keeps_the_end_and_reports_it_once_and_an_emptied_field_is_empty() {
let mut start = BoxConstraints::default();
start.constraint = BoxConstraint::FixedSize;
start.fixed = (Some(100.0), Some(50.0));
let start = BoxConstraints { constraint: BoxConstraint::FixedSize, fixed: (Some(100.0), Some(50.0)), ..Default::default() };
let (mut fixture, host) = gear(start);
type_into(&mut fixture, "Fixed Size W", "400000");
assert_eq!(host.borrow().value.fixed, (Some(300_000.0), Some(50.0)), "a width past 300,000 keeps 300,000");
+1 -2
View File
@@ -161,8 +161,7 @@ fn shift_squares_the_box_from_the_shorter_side() {
/// A Rectangle drag under the gear `constraint` with `change` applied to the gear's values.
fn gear(constraint: BoxConstraint, change: impl FnOnce(&mut BoxConstraints)) -> Shapes {
let mut constraints = BoxConstraints::default();
constraints.constraint = constraint;
let mut constraints = BoxConstraints { constraint, ..Default::default() };
change(&mut constraints);
Shapes::new(ShapeDragOptions::new(ShapeKind::Rectangle).constraints(constraints))
}
+1 -1
View File
@@ -776,7 +776,7 @@ fn a_secondary_click_on_the_box_opens_the_mode_menu() {
});
});
fixture.settle();
let mut right_click = |fixture: &mut Fixture, at: Pos2| {
let right_click = |fixture: &mut Fixture, at: Pos2| {
fixture.frame(vec![pointer::moved(at)]);
fixture.frame(vec![pointer::secondary(at, true)]);
fixture.frame(vec![pointer::secondary(at, false)]);
+2
View File
@@ -914,6 +914,8 @@ fn the_magnetic_lasso_shows_the_width_circle_under_the_precise_cursor() {
#[trial]
fn width_steps_by_one_and_shift_jumps_to_the_limits() {
let mut settings = MagneticSettings::default();
settings.step_width(1, false);
assert_eq!(settings.width, 11.0, "a step adds one to the default width");
settings.width = 10.4;
settings.step_width(1, false);
assert_eq!(settings.width, 11.0, "a step adds one to the rounded width");
+7 -2
View File
@@ -380,17 +380,22 @@ fn closed_styled_previews_leave_their_composites_to_eviction() {
// With nearest interpolation every zoom and scale gives level 0 with nearest filtering.
/// A preview with the scale it is painted at.
type PaintedPreview = (Rc<PreviewTextures>, f32);
/// The texture and size a painted preview showed.
type ShownPreview = (egui::TextureId, [f32; 2]);
/// Previews painted every frame of a fixture whose host runs jobs only when a trial says (upstream's 5 × 3 white
/// image).
struct Mips {
fixture: Fixture,
jobs: Arc<ManualJobs>,
/// The previews the next frames paint, each at its scale.
painted: Rc<RefCell<Vec<(Rc<PreviewTextures>, f32)>>>,
painted: Rc<RefCell<Vec<PaintedPreview>>>,
/// The display every painted preview is converted for.
display: Rc<RefCell<Option<PreviewDisplay>>>,
/// What each painted preview showed in the last frame.
shown: Rc<RefCell<Vec<Option<(egui::TextureId, [f32; 2])>>>>,
shown: Rc<RefCell<Vec<Option<ShownPreview>>>>,
/// The previews' uploads in the last frame, read in the frame.
uploads: Rc<Cell<usize>>,
}
+4 -4
View File
@@ -13,7 +13,7 @@
//! [`crate::guard::entities_expand_past`], [`crate::guard::too_wide`] (attributes an element),
//! [`crate::guard::prescan`] (nesting in the text),
//! [`height`] (nesting with references followed, as usvg walks them), then usvg.
//! [`image_resolver`] bounds the SVG documents embedded in `<image>` data URLs the same way.
//! `image_resolver` (with the `tree` feature) bounds the SVG documents embedded in `<image>` data URLs the same way.
//! [`draw`] bounds what drawing a tree with resvg allocates.
//!
//! Stack: usvg uses about 15 kB of stack for each level of nesting (measured natively by
@@ -66,9 +66,9 @@ pub struct Limits {
/// Accept a document type declaration; `false` refuses any `<!DOCTYPE`.
pub allow_dtd: bool,
/// Bytes of all SVG documents embedded in `<image>` data URLs, unpacked, for
/// [`image_resolver`].
/// `image_resolver`.
pub embedded_bytes: usize,
/// SVG documents embedded inside one another, for [`image_resolver`].
/// SVG documents embedded inside one another, for `image_resolver`.
pub embedded_depth: usize,
/// Decoded RGBA pixels retained across the raster images embedded in one drawing. Dimensions
/// are probed before usvg hands the bytes to a decoder; repeated references to the same data
@@ -137,7 +137,7 @@ pub fn text<'a>(bytes: &'a [u8], limits: &Limits) -> Result<Cow<'a, str>, Error>
}
/// The tree of an SVG or SVGZ file, within `limits`. `options` are usvg's: fonts, the default
/// size, and the image resolver ([`image_resolver`] unless the caller reads linked files).
/// size, and the image resolver (`image_resolver` unless the caller reads linked files).
pub fn parse(bytes: &[u8], limits: &Limits, options: &usvg::Options<'_>) -> Result<usvg::Tree, Error> {
parse_text(&svgz::text(bytes, limits.bytes)?, limits, options)
}
+2 -2
View File
@@ -4,8 +4,8 @@
//!
//! A path is a primitive when it is one closed contour whose points all lie on the outline of
//! an axis-aligned (rounded) rectangle or ellipse and that encloses its area. The check works on
//! the segments as given, so use it on a [`Coordinates::Local`](super::document::Coordinates)
//! scene, where a rotated or skewed shape keeps its own axes.
//! the segments as given (a [`Path`](super::document::Path)'s are after its absolute transform), so
//! a rotated or skewed shape is not recognised.
use super::document::Segment;
@@ -31,8 +31,12 @@ fn canvas_size() -> HostedCanvasSize {
}
#[allow(clippy::redundant_closure, reason = "the builder must be generic over the bind's lifetime, which the bare path is not")]
fn image_size_of(values: ImageSizeValues) -> HostedImageSize {
HostedImageSize::new(values, |values| ImageSize::new(values))
}
fn image_size() -> HostedImageSize {
HostedImageSize::new(ImageSizeValues::new(PICTURE), |values| ImageSize::new(values))
image_size_of(ImageSizeValues::new(PICTURE))
}
/// The document of the guide dialogs: 3000 × 2000 px at 300 ppi, measured in pixels.
@@ -437,7 +441,7 @@ fn image_size_alt_digits_pick_resample_without_typing_into_a_field() {
fixture.settle();
// Resample off: the keys pick nothing and type nothing into the resolution field.
host.borrow_mut().open(HostedImageSize::new(ImageSizeValues::new(PICTURE).resampling(false), |values| ImageSize::new(values)));
host.borrow_mut().open(image_size_of(ImageSizeValues::new(PICTURE).resampling(false)));
fixture.settle();
let resolution = fixture.by_label("Resolution").expect("the Resolution field");
fixture.click(&resolution).settle();
+2 -2
View File
@@ -44,10 +44,10 @@ fn a_number_field_that_keeps_its_name_is_described_by_its_caption() {
let node = NodeKey::of(field.get());
let described: Vec<Option<&str>> = tree.described_by(field.get()).into_iter().map(|key| tree.name_of(key)).collect();
if keeps {
assert_eq!(name(&tree, node), Some("Clone Source X Offset"), "the field keeps its own name");
assert_eq!(name(tree, node), Some("Clone Source X Offset"), "the field keeps its own name");
assert!(described.contains(&Some("X")), "the caption describes the field: {described:?}");
} else {
assert_eq!(name(&tree, node), Some("X"), "the caption names the field");
assert_eq!(name(tree, node), Some("X"), "the caption names the field");
}
}
}
+5 -2
View File
@@ -459,8 +459,11 @@ fn a_draft_that_is_no_number_owes_no_range_alert() {
use craft_ui::text::RangeAlert;
use std::rc::Rc;
/// A step run after the typing: it gets the fixture and a way to type text.
type Step<'a> = &'a dyn Fn(&mut Fixture, &dyn Fn(&mut Fixture, &str));
/// Types "150" over the field without leaving it, then runs `then`; returns the alerts and the value after.
fn after_150(then: &dyn Fn(&mut Fixture, &dyn Fn(&mut Fixture, &str))) -> (usize, Option<f64>) {
fn after_150(then: Step<'_>) -> (usize, Option<f64>) {
let value = Rc::new(Cell::new(Some(50.0)));
let alerts: Rc<RefCell<Vec<RangeAlert>>> = Rc::default();
let (held, seen) = (value.clone(), alerts.clone());
@@ -488,7 +491,7 @@ fn a_draft_that_is_no_number_owes_no_range_alert() {
let tab = |fixture: &mut Fixture| {
fixture.key(Key::Tab, Modifiers::NONE);
};
let cases: [(&str, &dyn Fn(&mut Fixture, &dyn Fn(&mut Fixture, &str)), usize); 4] = [
let cases: [(&str, Step<'_>, usize); 4] = [
(
"text typed over it, then Tab",
&|fixture: &mut Fixture, type_over: &dyn Fn(&mut Fixture, &str)| {