Skip to content

Commit c9baf96

Browse files
authored
Merge pull request #361 from kas-gui/work
Rustfmt: adjust opts and format within macro braces
2 parents 7993fb5 + b90f126 commit c9baf96

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+401
-287
lines changed

.rustfmt.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This may be useful to run occasionally, but has issues:
2+
#format_code_in_doc_comments = true
3+
4+
inline_attribute_width = 60
5+
overflow_delimited_expr = true
6+
single_line_if_else_max_width = 60
7+
use_field_init_shorthand = true
8+
use_try_shorthand = true

crates/kas-core/src/core/data.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55

66
//! Widget data types
77
8-
#[allow(unused)]
9-
use super::Layout;
8+
#[allow(unused)] use super::Layout;
109
use super::{Widget, WidgetId};
1110
use crate::dir::Direction;
1211
use crate::event::EventMgr;
1312
use crate::geom::Rect;
1413

15-
#[cfg(feature = "winit")]
16-
pub use winit::window::Icon;
14+
#[cfg(feature = "winit")] pub use winit::window::Icon;
1715

1816
/// An icon used for the window titlebar, taskbar, etc.
1917
#[cfg(not(feature = "winit"))]

crates/kas-core/src/core/widget.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,11 @@ use crate::util::IdentifyWidget;
1515
use crate::WidgetId;
1616
use kas_macros::autoimpl;
1717

18-
#[allow(unused)]
19-
use crate::event::EventState;
18+
#[allow(unused)] use crate::event::EventState;
2019
#[allow(unused)]
2120
use crate::layout::{self, AlignPair, AutoLayout};
22-
#[allow(unused)]
23-
use crate::TkAction;
24-
#[allow(unused)]
25-
use kas_macros as macros;
21+
#[allow(unused)] use crate::TkAction;
22+
#[allow(unused)] use kas_macros as macros;
2623

2724
/// Base functionality for [`Widget`]s
2825
///
@@ -309,8 +306,8 @@ pub trait Layout {
309306
/// and [`kas_widgets` code](https://github.com/kas-gui/kas/tree/master/crates/kas-widgets).
310307
/// ```
311308
/// # extern crate kas_core as kas;
312-
/// use kas::prelude::*;
313309
/// use kas::event;
310+
/// use kas::prelude::*;
314311
/// use kas::theme::TextClass;
315312
/// use std::fmt::Debug;
316313
///

crates/kas-core/src/dir.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,12 @@ pub enum Direction {
9999

100100
impl fmt::Display for Direction {
101101
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
102-
write!(
103-
f,
104-
"{}",
105-
match self {
106-
Direction::Right => "Right",
107-
Direction::Down => "Down",
108-
Direction::Left => "Left",
109-
Direction::Up => "Up",
110-
}
111-
)
102+
write!(f, "{}", match self {
103+
Direction::Right => "Right",
104+
Direction::Down => "Down",
105+
Direction::Left => "Left",
106+
Direction::Up => "Up",
107+
})
112108
}
113109
}
114110

crates/kas-core/src/draw/draw.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
//! Drawing APIs — draw interface
77
88
use super::{color::Rgba, AnimationState};
9-
#[allow(unused)]
10-
use super::{DrawRounded, DrawRoundedImpl};
9+
#[allow(unused)] use super::{DrawRounded, DrawRoundedImpl};
1110
use super::{DrawShared, DrawSharedImpl, ImageId, PassId, PassType, SharedState};
1211
use crate::geom::{Offset, Quad, Rect};
13-
#[allow(unused)]
14-
use crate::text::TextApi;
12+
#[allow(unused)] use crate::text::TextApi;
1513
use crate::text::{Effect, TextDisplay};
1614
use std::any::Any;
1715
use std::time::Instant;

crates/kas-core/src/draw/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@
3737
3838
pub mod color;
3939

40-
#[allow(clippy::module_inception)]
41-
mod draw;
40+
#[allow(clippy::module_inception)] mod draw;
4241
mod draw_rounded;
4342
mod draw_shared;
4443

4544
use crate::cast::Cast;
46-
#[allow(unused)]
47-
use crate::theme::DrawMgr;
45+
#[allow(unused)] use crate::theme::DrawMgr;
4846

4947
pub use draw::{Draw, DrawIface, DrawImpl};
5048
pub use draw_rounded::{DrawRounded, DrawRoundedImpl};

crates/kas-core/src/event/components.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ use super::ScrollDelta::{LineDelta, PixelDelta};
99
use super::{Command, CursorIcon, Event, EventMgr, PressSource, Response, Scroll};
1010
use crate::cast::traits::*;
1111
use crate::geom::{Coord, Offset, Rect, Size, Vec2};
12-
#[allow(unused)]
13-
use crate::text::SelectionHelper;
12+
#[allow(unused)] use crate::text::SelectionHelper;
1413
use crate::{TkAction, WidgetId};
1514
use kas_macros::impl_default;
1615
use std::time::{Duration, Instant};

crates/kas-core/src/event/config/shortcuts.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ use serde::de::{self, Deserialize, Deserializer, MapAccess, Unexpected, Visitor}
1212
#[cfg(feature = "config")]
1313
use serde::ser::{Serialize, SerializeMap, Serializer};
1414
use std::collections::HashMap;
15-
#[cfg(feature = "config")]
16-
use std::fmt;
15+
#[cfg(feature = "config")] use std::fmt;
1716

1817
/// Shortcut manager
1918
#[allow(clippy::derive_partial_eq_without_eq)]

crates/kas-core/src/event/events.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ use serde::{Deserialize, Serialize};
1212
use super::{EventMgr, EventState, GrabMode, Response}; // for doc-links
1313
use super::{MouseButton, UpdateId, VirtualKeyCode};
1414
use crate::geom::{Coord, DVec2, Offset};
15-
#[allow(unused)]
16-
use crate::Widget;
15+
#[allow(unused)] use crate::Widget;
1716
use crate::{dir::Direction, WidgetId, WindowId};
1817

1918
/// Events addressed to a widget
@@ -58,7 +57,7 @@ pub enum Event {
5857
/// # use kas_core::cast::{Cast, CastFloat};
5958
/// # use kas_core::geom::{Coord, DVec2};
6059
/// # let (alpha, delta) = (DVec2::ZERO, DVec2::ZERO);
61-
/// let mut p = Coord::ZERO; // or whatever
60+
/// let mut p = Coord::ZERO; // or whatever
6261
/// p = (alpha.complex_mul(p.cast()) + delta).cast_nearest();
6362
/// ```
6463
///

crates/kas-core/src/event/manager/config_mgr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ use crate::theme::{Feature, SizeMgr, TextClass, ThemeSize};
1515
use crate::{TkAction, Widget, WidgetExt, WidgetId};
1616
use std::ops::{Deref, DerefMut};
1717

18-
#[allow(unused)]
19-
use crate::{event::Event, Layout};
18+
#[allow(unused)] use crate::{event::Event, Layout};
2019

2120
/// Manager used to configure widgets and layout
2221
///

crates/kas-core/src/event/manager/mgr_pub.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ use crate::cast::Conv;
1313
use crate::draw::DrawShared;
1414
use crate::geom::{Coord, Offset, Vec2};
1515
use crate::theme::{SizeMgr, ThemeControl};
16-
#[allow(unused)]
17-
use crate::{Layout, Widget}; // for doc-links
16+
#[allow(unused)] use crate::{Layout, Widget}; // for doc-links
1817
use crate::{TkAction, WidgetId, WindowId};
1918

2019
impl<'a> std::ops::BitOrAssign<TkAction> for EventMgr<'a> {

crates/kas-core/src/event/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@
5454
//! [`Unused`]: Response::Unused
5555
5656
pub mod config;
57-
#[cfg(not(feature = "winit"))]
58-
mod enums;
57+
#[cfg(not(feature = "winit"))] mod enums;
5958
mod events;
6059
mod manager;
6160
mod response;
@@ -68,13 +67,10 @@ use std::fmt::Debug;
6867

6968
#[cfg(feature = "winit")]
7069
pub use winit::event::{ModifiersState, MouseButton, VirtualKeyCode};
71-
#[cfg(feature = "winit")]
72-
pub use winit::window::CursorIcon;
70+
#[cfg(feature = "winit")] pub use winit::window::CursorIcon;
7371

74-
#[allow(unused)]
75-
use crate::Widget;
76-
#[doc(no_inline)]
77-
pub use config::Config;
72+
#[allow(unused)] use crate::Widget;
73+
#[doc(no_inline)] pub use config::Config;
7874
#[cfg(not(feature = "winit"))]
7975
pub use enums::{CursorIcon, ModifiersState, MouseButton, VirtualKeyCode};
8076
pub use events::*;

crates/kas-core/src/layout/align.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
//! Alignment types
77
8-
#[allow(unused)]
9-
use super::Stretch; // for doc-links
8+
#[allow(unused)] use super::Stretch; // for doc-links
109
use crate::dir::Directional;
1110
use crate::geom::{Rect, Size};
1211

crates/kas-core/src/layout/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ use crate::geom::{Coord, Rect};
5151
use crate::theme::{DrawMgr, SizeMgr};
5252
use crate::WidgetId;
5353

54-
#[allow(unused)]
55-
use crate::Layout;
54+
#[allow(unused)] use crate::Layout;
5655

5756
pub use align::{Align, AlignHints, AlignPair};
5857
pub use grid_solver::{DefaultWithLen, GridChildInfo, GridDimensions, GridSetter, GridSolver};

crates/kas-core/src/layout/size_rules.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ use crate::dir::Directional;
1414
use crate::geom::Size;
1515

1616
// for doc use
17-
#[allow(unused)]
18-
use super::FrameRules;
19-
#[allow(unused)]
20-
use crate::theme::SizeMgr;
17+
#[allow(unused)] use super::FrameRules;
18+
#[allow(unused)] use crate::theme::SizeMgr;
2119

2220
/// Widget sizing information
2321
///

crates/kas-core/src/layout/size_types.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ use crate::theme::MarginStyle;
1313
use kas_macros::impl_scope;
1414

1515
// for doc use
16-
#[allow(unused)]
17-
use crate::theme::SizeMgr;
16+
#[allow(unused)] use crate::theme::SizeMgr;
1817

1918
/// Logical (pre-scaling) pixel size
2019
///

crates/kas-core/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020

2121
extern crate self as kas;
2222

23-
#[macro_use]
24-
extern crate bitflags;
23+
#[macro_use] extern crate bitflags;
2524

2625
pub extern crate easy_cast as cast;
2726
pub extern crate kas_macros as macros;

crates/kas-core/src/model/shared_arc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
//! `SharedArc` data type
77
8-
#[allow(unused)]
9-
use crate::event::Event;
8+
#[allow(unused)] use crate::event::Event;
109
use crate::event::{EventMgr, UpdateId};
1110
use crate::model::*;
1211
use std::fmt::Debug;

crates/kas-core/src/model/shared_rc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
//! `SharedRc` data type
77
8-
#[allow(unused)]
9-
use crate::event::Event;
8+
#[allow(unused)] use crate::event::Event;
109
use crate::event::{EventMgr, UpdateId};
1110
use crate::model::*;
1211
use std::cell::{Ref, RefCell, RefMut};

crates/kas-core/src/prelude.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
//! It is recommended to use `kas::prelude` instead, which is an extension of
99
//! this crate's prelude.
1010
11-
#[doc(no_inline)]
12-
pub use crate::cast::traits::*;
13-
#[doc(no_inline)]
14-
pub use crate::class::*;
11+
#[doc(no_inline)] pub use crate::cast::traits::*;
12+
#[doc(no_inline)] pub use crate::class::*;
1513
#[doc(no_inline)]
1614
pub use crate::dir::{Direction, Directional};
1715
#[doc(no_inline)]
@@ -22,16 +20,12 @@ pub use crate::geom::{Coord, Offset, Rect, Size};
2220
pub use crate::layout::{Align, AlignPair, AxisInfo, SizeRules, Stretch};
2321
#[doc(no_inline)]
2422
pub use crate::macros::{autoimpl, impl_default, impl_scope, singleton, widget, widget_index};
25-
#[doc(no_inline)]
26-
pub use crate::text::AccelString;
23+
#[doc(no_inline)] pub use crate::text::AccelString;
2724
#[doc(no_inline)]
2825
pub use crate::text::{EditableTextApi, Text, TextApi, TextApiExt};
29-
#[doc(no_inline)]
30-
pub use crate::theme::{DrawMgr, SizeMgr};
31-
#[doc(no_inline)]
32-
pub use crate::TkAction;
33-
#[doc(no_inline)]
34-
pub use crate::WidgetId;
26+
#[doc(no_inline)] pub use crate::theme::{DrawMgr, SizeMgr};
27+
#[doc(no_inline)] pub use crate::TkAction;
28+
#[doc(no_inline)] pub use crate::WidgetId;
3529
#[doc(no_inline)]
3630
pub use crate::{HasScrollBars, ScrollBarMode, Scrollable};
3731
#[doc(no_inline)]

crates/kas-core/src/text.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
//!
1616
//! [KAS Text]: https://github.com/kas-gui/kas-text/
1717
18-
#[allow(unused)]
19-
use kas::{event::ConfigMgr, Layout};
18+
#[allow(unused)] use kas::{event::ConfigMgr, Layout};
2019

2120
pub use kas_text::*;
2221

crates/kas-core/src/theme/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ pub use draw::{Background, DrawMgr, ThemeDraw};
1313
pub use size::{SizeMgr, ThemeSize};
1414
pub use style::*;
1515

16-
#[allow(unused)]
17-
use crate::event::EventMgr;
16+
#[allow(unused)] use crate::event::EventMgr;
1817
use crate::TkAction;
1918
use std::ops::{Deref, DerefMut};
2019

crates/kas-core/src/theme/size.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ use crate::layout::{AlignPair, AxisInfo, FrameRules, Margins, SizeRules};
1414
use crate::macros::autoimpl;
1515
use crate::text::TextApi;
1616

17-
#[allow(unused)]
18-
use crate::text::TextApiExt;
17+
#[allow(unused)] use crate::text::TextApiExt;
1918
#[allow(unused)]
2019
use crate::{event::ConfigMgr, layout::Stretch, theme::DrawMgr};
2120

crates/kas-dylib/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
#![allow(clippy::single_component_path_imports)]
1313

1414
use kas_core;
15-
#[cfg(feature = "kas-resvg")]
16-
use kas_resvg;
15+
#[cfg(feature = "kas-resvg")] use kas_resvg;
1716
use kas_theme;
1817
use kas_wgpu;
1918
use kas_widgets;

crates/kas-macros/src/widget.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,7 @@ pub fn widget(mut args: WidgetArgs, scope: &mut Scope) -> Result<()> {
687687
set_rect = quote! {
688688
<Self as ::kas::layout::AutoLayout>::set_rect(self, mgr, rect);
689689
};
690-
find_id = quote! {
691-
<Self as ::kas::layout::AutoLayout>::find_id(self, coord)
692-
};
690+
find_id = quote! { <Self as ::kas::layout::AutoLayout>::find_id(self, coord) };
693691
fn_draw = Some(quote! {
694692
fn draw(&mut self, draw: ::kas::theme::DrawMgr) {
695693
<Self as ::kas::layout::AutoLayout>::draw(self, draw);

crates/kas-resvg/src/canvas.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl_scope! {
4646
/// The canvas (re)creates the backing pixmap when the size is set and draws
4747
/// to the new pixmap immediately. If the canvas program is modified then
4848
/// [`Canvas::redraw`] must be called to update the pixmap.
49-
#[derive(Clone, Debug,)]
49+
#[derive(Clone, Debug)]
5050
#[widget]
5151
pub struct Canvas<P: CanvasProgram> {
5252
core: widget_core!(),
@@ -118,7 +118,8 @@ impl_scope! {
118118
if let Some((pm, h)) = self.pixmap.as_mut().zip(self.image.as_ref()) {
119119
pm.fill(Color::TRANSPARENT);
120120
self.program.draw(pm);
121-
mgr.draw_shared().image_upload(h, pm.data(), ImageFormat::Rgba8);
121+
mgr.draw_shared()
122+
.image_upload(h, pm.data(), ImageFormat::Rgba8);
122123
}
123124
}
124125
}
@@ -144,7 +145,8 @@ impl_scope! {
144145
program.draw(pm);
145146
let (w, h) = (pm.width(), pm.height());
146147
let handle = mgr.draw_shared().image_alloc((w, h)).unwrap();
147-
mgr.draw_shared().image_upload(&handle, pm.data(), ImageFormat::Rgba8);
148+
mgr.draw_shared()
149+
.image_upload(&handle, pm.data(), ImageFormat::Rgba8);
148150
handle
149151
});
150152
}

crates/kas-resvg/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,5 @@ pub extern crate tiny_skia;
1818
mod canvas;
1919
pub use canvas::{Canvas, CanvasProgram};
2020

21-
#[cfg(feature = "svg")]
22-
mod svg;
23-
#[cfg(feature = "svg")]
24-
pub use svg::Svg;
21+
#[cfg(feature = "svg")] mod svg;
22+
#[cfg(feature = "svg")] pub use svg::Svg;

0 commit comments

Comments
 (0)