Skip to content

Commit

Permalink
Merge branch 'master' into text-editor
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Oct 27, 2023
2 parents 8cc19de + f1b1344 commit 6582387
Show file tree
Hide file tree
Showing 109 changed files with 370 additions and 413 deletions.
55 changes: 55 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[alias]
lint = """
clippy --workspace --no-deps -- \
-D warnings \
-A clippy::type_complexity \
-D clippy::semicolon_if_nothing_returned \
-D clippy::trivially-copy-pass-by-ref \
-D clippy::default_trait_access \
-D clippy::match-wildcard-for-single-variants \
-D clippy::redundant-closure-for-method-calls \
-D clippy::filter_map_next \
-D clippy::manual_let_else \
-D clippy::unused_async \
-D clippy::from_over_into \
-D clippy::needless_borrow \
-D clippy::new_without_default \
-D clippy::useless_conversion
"""

#![allow(clippy::inherent_to_string, clippy::type_complexity)]

nitpick = """
clippy --workspace --no-deps -- \
-D warnings \
-D clippy::pedantic \
-A clippy::type_complexity \
-A clippy::must_use_candidate \
-A clippy::return_self_not_must_use \
-A clippy::needless_pass_by_value \
-A clippy::cast_precision_loss \
-A clippy::cast_sign_loss \
-A clippy::cast_possible_truncation \
-A clippy::match_same_arms \
-A clippy::missing-errors-doc \
-A clippy::missing-panics-doc \
-A clippy::cast_lossless \
-A clippy::doc_markdown \
-A clippy::items_after_statements \
-A clippy::too_many_lines \
-A clippy::module_name_repetitions \
-A clippy::if_not_else \
-A clippy::redundant_else \
-A clippy::used_underscore_binding \
-A clippy::cast_possible_wrap \
-A clippy::unnecessary_wraps \
-A clippy::struct-excessive-bools \
-A clippy::float-cmp \
-A clippy::single_match_else \
-A clippy::unreadable_literal \
-A clippy::explicit_deref_methods \
-A clippy::map_unwrap_or \
-A clippy::unnested_or_patterns \
-A clippy::similar_names \
-A clippy::unused_self
"""
2 changes: 2 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
- name: Install cargo-audit
run: cargo install cargo-audit
- uses: actions/checkout@master
- name: Resolve dependencies
run: cargo update
- name: Audit vulnerabilities
run: cargo audit

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ jobs:
- uses: actions/checkout@master
- name: Enable static CRT linkage
run: |
mkdir .cargo
echo '[target.x86_64-pc-windows-msvc]' >> .cargo/config
echo 'rustflags = ["-Ctarget-feature=+crt-static"]' >> .cargo/config
- name: Run the application without starting the shell
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ jobs:
components: clippy
- uses: actions/checkout@master
- name: Check lints
run: cargo clippy --workspace --all-features --all-targets --no-deps -- -D warnings
run: cargo lint
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ target/
pkg/
**/*.rs.bk
Cargo.lock
.cargo/
dist/
traces/
2 changes: 1 addition & 1 deletion core/src/color.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(feature = "palette")]
use palette::rgb::{Srgb, Srgba};

/// A color in the sRGB color space.
/// A color in the `sRGB` color space.
#[derive(Debug, Clone, Copy, PartialEq, Default)]
pub struct Color {
/// Red component, 0.0 - 1.0
Expand Down
6 changes: 3 additions & 3 deletions core/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ where
}

fn diff(&self, tree: &mut Tree) {
self.widget.diff(tree)
self.widget.diff(tree);
}

fn width(&self) -> Length {
Expand Down Expand Up @@ -418,7 +418,7 @@ where
viewport: &Rectangle,
) {
self.widget
.draw(tree, renderer, theme, style, layout, cursor, viewport)
.draw(tree, renderer, theme, style, layout, cursor, viewport);
}

fn mouse_interaction(
Expand Down Expand Up @@ -508,7 +508,7 @@ where
) {
self.element
.widget
.operate(state, layout, renderer, operation)
.operate(state, layout, renderer, operation);
}

fn on_event(
Expand Down
4 changes: 2 additions & 2 deletions core/src/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ impl Linear {
mut self,
stops: impl IntoIterator<Item = ColorStop>,
) -> Self {
for stop in stops.into_iter() {
self = self.add_stop(stop.offset, stop.color)
for stop in stops {
self = self.add_stop(stop.offset, stop.color);
}

self
Expand Down
2 changes: 1 addition & 1 deletion core/src/hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub struct Hasher(twox_hash::XxHash64);

impl core::hash::Hasher for Hasher {
fn write(&mut self, bytes: &[u8]) {
self.0.write(bytes)
self.0.write(bytes);
}

fn finish(&self) -> u64 {
Expand Down
6 changes: 0 additions & 6 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,8 @@
missing_debug_implementations,
// missing_docs,
unused_results,
clippy::extra_unused_lifetimes,
clippy::from_over_into,
clippy::needless_borrow,
clippy::new_without_default,
clippy::useless_conversion,
rustdoc::broken_intra_doc_links
)]
#![allow(clippy::inherent_to_string, clippy::type_complexity)]
pub mod alignment;
pub mod clipboard;
pub mod event;
Expand Down
2 changes: 1 addition & 1 deletion core/src/mouse/click.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub enum Kind {
}

impl Kind {
fn next(&self) -> Kind {
fn next(self) -> Kind {
match self {
Kind::Single => Kind::Double,
Kind::Double => Kind::Triple,
Expand Down
6 changes: 3 additions & 3 deletions core/src/overlay/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ where
layout: Layout<'_>,
cursor: mouse::Cursor,
) {
self.overlay.draw(renderer, theme, style, layout, cursor)
self.overlay.draw(renderer, theme, style, layout, cursor);
}

/// Applies a [`widget::Operation`] to the [`Element`].
Expand Down Expand Up @@ -205,7 +205,7 @@ where
state: &mut dyn widget::operation::TextInput,
id: Option<&widget::Id>,
) {
self.operation.text_input(state, id)
self.operation.text_input(state, id);
}

fn custom(&mut self, state: &mut dyn Any, id: Option<&widget::Id>) {
Expand Down Expand Up @@ -262,7 +262,7 @@ where
layout: Layout<'_>,
cursor: mouse::Cursor,
) {
self.content.draw(renderer, theme, style, layout, cursor)
self.content.draw(renderer, theme, style, layout, cursor);
}

fn is_over(
Expand Down
2 changes: 1 addition & 1 deletion core/src/overlay/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ where
|(child, layout)| {
child.operate(layout, renderer, operation);
},
)
);
});
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<'a, Message> Shell<'a, Message> {
if self.is_layout_invalid {
self.is_layout_invalid = false;

f()
f();
}
}

Expand Down
10 changes: 5 additions & 5 deletions core/src/widget/operation/focusable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn focus<T>(target: Id) -> impl Operation<T> {
_bounds: Rectangle,
operate_on_children: &mut dyn FnMut(&mut dyn Operation<T>),
) {
operate_on_children(self)
operate_on_children(self);
}
}

Expand Down Expand Up @@ -85,7 +85,7 @@ where
_bounds: Rectangle,
operate_on_children: &mut dyn FnMut(&mut dyn Operation<T>),
) {
operate_on_children(self)
operate_on_children(self);
}

fn finish(&self) -> Outcome<T> {
Expand Down Expand Up @@ -132,7 +132,7 @@ pub fn focus_previous<T>() -> impl Operation<T> {
_bounds: Rectangle,
operate_on_children: &mut dyn FnMut(&mut dyn Operation<T>),
) {
operate_on_children(self)
operate_on_children(self);
}
}

Expand Down Expand Up @@ -166,7 +166,7 @@ pub fn focus_next<T>() -> impl Operation<T> {
_bounds: Rectangle,
operate_on_children: &mut dyn FnMut(&mut dyn Operation<T>),
) {
operate_on_children(self)
operate_on_children(self);
}
}

Expand All @@ -193,7 +193,7 @@ pub fn find_focused() -> impl Operation<Id> {
_bounds: Rectangle,
operate_on_children: &mut dyn FnMut(&mut dyn Operation<Id>),
) {
operate_on_children(self)
operate_on_children(self);
}

fn finish(&self) -> Outcome<Id> {
Expand Down
4 changes: 2 additions & 2 deletions core/src/widget/operation/scrollable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn snap_to<T>(target: Id, offset: RelativeOffset) -> impl Operation<T> {
_bounds: Rectangle,
operate_on_children: &mut dyn FnMut(&mut dyn Operation<T>),
) {
operate_on_children(self)
operate_on_children(self);
}

fn scrollable(
Expand Down Expand Up @@ -60,7 +60,7 @@ pub fn scroll_to<T>(target: Id, offset: AbsoluteOffset) -> impl Operation<T> {
_bounds: Rectangle,
operate_on_children: &mut dyn FnMut(&mut dyn Operation<T>),
) {
operate_on_children(self)
operate_on_children(self);
}

fn scrollable(
Expand Down
8 changes: 4 additions & 4 deletions core/src/widget/operation/text_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn move_cursor_to_front<T>(target: Id) -> impl Operation<T> {
_bounds: Rectangle,
operate_on_children: &mut dyn FnMut(&mut dyn Operation<T>),
) {
operate_on_children(self)
operate_on_children(self);
}
}

Expand Down Expand Up @@ -68,7 +68,7 @@ pub fn move_cursor_to_end<T>(target: Id) -> impl Operation<T> {
_bounds: Rectangle,
operate_on_children: &mut dyn FnMut(&mut dyn Operation<T>),
) {
operate_on_children(self)
operate_on_children(self);
}
}

Expand Down Expand Up @@ -99,7 +99,7 @@ pub fn move_cursor_to<T>(target: Id, position: usize) -> impl Operation<T> {
_bounds: Rectangle,
operate_on_children: &mut dyn FnMut(&mut dyn Operation<T>),
) {
operate_on_children(self)
operate_on_children(self);
}
}

Expand Down Expand Up @@ -128,7 +128,7 @@ pub fn select_all<T>(target: Id) -> impl Operation<T> {
_bounds: Rectangle,
operate_on_children: &mut dyn FnMut(&mut dyn Operation<T>),
) {
operate_on_children(self)
operate_on_children(self);
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/widget/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ where
size,
line_height,
font,
shaping,
horizontal_alignment,
vertical_alignment,
shaping,
});

let size = limits.resolve(paragraph.min_bounds());
Expand Down
4 changes: 2 additions & 2 deletions core/src/widget/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl Tree {
Renderer: crate::Renderer,
{
if self.tag == new.borrow().tag() {
new.borrow().diff(self)
new.borrow().diff(self);
} else {
*self = Self::new(new);
}
Expand All @@ -78,7 +78,7 @@ impl Tree {
new_children,
|tree, widget| tree.diff(widget.borrow()),
|widget| Self::new(widget.borrow()),
)
);
}

/// Reconciliates the children of the tree with the provided list of widgets using custom
Expand Down
2 changes: 1 addition & 1 deletion core/src/window/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::Size;

use std::mem;

/// Builds an [`Icon`] from its RGBA pixels in the sRGB color space.
/// Builds an [`Icon`] from its RGBA pixels in the `sRGB` color space.
pub fn from_rgba(
rgba: Vec<u8>,
width: u32,
Expand Down
2 changes: 1 addition & 1 deletion examples/arc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Application for Arc {
(
Arc {
start: Instant::now(),
cache: Default::default(),
cache: Cache::default(),
},
Command::none(),
)
Expand Down
11 changes: 4 additions & 7 deletions examples/bezier_tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ mod bezier {
}

pub fn request_redraw(&mut self) {
self.cache.clear()
self.cache.clear();
}
}

Expand All @@ -100,12 +100,9 @@ mod bezier {
bounds: Rectangle,
cursor: mouse::Cursor,
) -> (event::Status, Option<Curve>) {
let cursor_position =
if let Some(position) = cursor.position_in(bounds) {
position
} else {
return (event::Status::Ignored, None);
};
let Some(cursor_position) = cursor.position_in(bounds) else {
return (event::Status::Ignored, None);
};

match event {
Event::Mouse(mouse_event) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/clock/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Application for Clock {
Clock {
now: time::OffsetDateTime::now_local()
.unwrap_or_else(|_| time::OffsetDateTime::now_utc()),
clock: Default::default(),
clock: Cache::default(),
},
Command::none(),
)
Expand Down Expand Up @@ -141,7 +141,7 @@ impl<Message> canvas::Program<Message, Renderer> for Clock {
frame.with_save(|frame| {
frame.rotate(hand_rotation(self.now.second(), 60));
frame.stroke(&long_hand, thin_stroke());
})
});
});

vec![clock]
Expand Down
Loading

0 comments on commit 6582387

Please sign in to comment.