Skip to content

Commit 5696afc

Browse files
committed
Ran cargo_fmt over changed files.
1 parent a88aae5 commit 5696afc

6 files changed

Lines changed: 53 additions & 55 deletions

File tree

native/src/widget/icon.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
//! Display an icon.
2-
use crate::{layout, Element, Hasher, Layout, Length, Point, Rectangle, Widget};
2+
use crate::{
3+
layout, Element, Hasher, Layout, Length, Point, Rectangle, Widget,
4+
};
35

4-
use std::hash::Hash;
5-
use std::path::{Path, PathBuf};
6+
use std::{
7+
hash::Hash,
8+
path::{Path, PathBuf},
9+
};
610

711
/// A simple icon_loader widget.
812
#[derive(Debug, Clone)]
@@ -63,10 +67,7 @@ where
6367
) -> Renderer::Output {
6468
let bounds = layout.bounds();
6569

66-
renderer.draw(
67-
bounds,
68-
self.path.as_path(),
69-
)
70+
renderer.draw(bounds, self.path.as_path())
7071
}
7172

7273
fn hash_layout(&self, state: &mut Hasher) {
@@ -86,11 +87,7 @@ pub trait Renderer: crate::Renderer {
8687
/// Draws an [`Icon`].
8788
///
8889
/// [`Icon`]: struct.Icon.html
89-
fn draw(
90-
&mut self,
91-
bounds: Rectangle,
92-
path: &Path,
93-
) -> Self::Output;
90+
fn draw(&mut self, bounds: Rectangle, path: &Path) -> Self::Output;
9491
}
9592

9693
impl<'a, Message, Renderer> From<Icon> for Element<'a, Message, Renderer>

src/native.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ pub mod widget {
8989

9090
#[doc(no_inline)]
9191
pub use {
92-
button::Button, icon::Icon, image::Image, scrollable::Scrollable, slider::Slider,
93-
text_input::TextInput,
92+
button::Button, icon::Icon, image::Image, scrollable::Scrollable,
93+
slider::Slider, text_input::TextInput,
9494
};
9595

9696
/// A container that distributes its contents vertically.

wgpu/src/renderer.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,11 @@ impl Renderer {
243243
scale: [bounds.width, bounds.height],
244244
});
245245
}
246-
Primitive::Svg { handle, bounds } => {
247-
layer.svgs.push(Svg {
248-
handle: handle.clone(),
249-
position: [bounds.x, bounds.y],
250-
scale: [bounds.width, bounds.height],
251-
})
252-
},
246+
Primitive::Svg { handle, bounds } => layer.svgs.push(Svg {
247+
handle: handle.clone(),
248+
position: [bounds.x, bounds.y],
249+
scale: [bounds.width, bounds.height],
250+
}),
253251
Primitive::Clip {
254252
bounds,
255253
offset,

wgpu/src/renderer/widget/icon.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
use crate::{svg::Handle, Primitive, Renderer};
2-
use iced_native::{
3-
icon, MouseCursor, Rectangle,
4-
};
2+
use iced_native::{icon, MouseCursor, Rectangle};
53
use std::path::Path;
64

75
impl icon::Renderer for Renderer {
8-
fn draw(
9-
&mut self,
10-
bounds: Rectangle,
11-
path: &Path,
12-
) -> Self::Output {
6+
fn draw(&mut self, bounds: Rectangle, path: &Path) -> Self::Output {
137
(
148
Primitive::Svg {
159
handle: Handle::from_path(path),
@@ -18,4 +12,4 @@ impl icon::Renderer for Renderer {
1812
MouseCursor::OutOfBounds,
1913
)
2014
}
21-
}
15+
}

wgpu/src/svg.rs

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use std::{
1212
u32,
1313
};
1414

15-
1615
#[derive(Debug)]
1716
pub struct Pipeline {
1817
cache: RefCell<Cache>,
@@ -220,10 +219,11 @@ impl Pipeline {
220219
opt.usvg.dpi = handle.dpi as f64;
221220
opt.usvg.font_size = handle.font_size as f64;
222221

223-
let mem = match resvg::usvg::Tree::from_file(&handle.path, &opt.usvg) {
224-
Ok(tree) => Memory::Host { tree },
225-
Err(_) => Memory::Invalid
226-
};
222+
let mem =
223+
match resvg::usvg::Tree::from_file(&handle.path, &opt.usvg) {
224+
Ok(tree) => Memory::Host { tree },
225+
Err(_) => Memory::Invalid,
226+
};
227227

228228
let _ = self.cache.borrow_mut().insert(&handle, mem);
229229
}
@@ -265,12 +265,14 @@ impl Pipeline {
265265

266266
self.load(&handle);
267267

268-
if let Some(texture) = self
269-
.cache
270-
.borrow_mut()
271-
.get(&handle)
272-
.unwrap()
273-
.upload(device, encoder, &self.texture_layout, svg.scale[0] as u32, svg.scale[1] as u32)
268+
if let Some(texture) =
269+
self.cache.borrow_mut().get(&handle).unwrap().upload(
270+
device,
271+
encoder,
272+
&self.texture_layout,
273+
svg.scale[0] as u32,
274+
svg.scale[1] as u32,
275+
)
274276
{
275277
let instance_buffer = device
276278
.create_buffer_mapped(1, wgpu::BufferUsage::COPY_SRC)
@@ -409,12 +411,8 @@ impl Hash for Handle {
409411
}
410412

411413
enum Memory {
412-
Host {
413-
tree: resvg::usvg::Tree,
414-
},
415-
Device {
416-
bind_group: Rc<wgpu::BindGroup>,
417-
},
414+
Host { tree: resvg::usvg::Tree },
415+
Device { bind_group: Rc<wgpu::BindGroup> },
418416
NotFound,
419417
Invalid,
420418
}
@@ -426,7 +424,7 @@ impl Memory {
426424
encoder: &mut wgpu::CommandEncoder,
427425
texture_layout: &wgpu::BindGroupLayout,
428426
width: u32,
429-
height: u32
427+
height: u32,
430428
) -> Option<Rc<wgpu::BindGroup>> {
431429
match self {
432430
Memory::Host { tree } => {
@@ -447,10 +445,17 @@ impl Memory {
447445
| wgpu::TextureUsage::SAMPLED,
448446
});
449447

450-
let mut canvas = resvg::raqote::DrawTarget::new(width as i32, height as i32);
448+
let mut canvas =
449+
resvg::raqote::DrawTarget::new(width as i32, height as i32);
451450
let opt = resvg::Options::default();
452-
let screen_size = resvg::ScreenSize::new(width, height).unwrap();
453-
resvg::backend_raqote::render_to_canvas(tree, &opt, screen_size, &mut canvas);
451+
let screen_size =
452+
resvg::ScreenSize::new(width, height).unwrap();
453+
resvg::backend_raqote::render_to_canvas(
454+
tree,
455+
&opt,
456+
screen_size,
457+
&mut canvas,
458+
);
454459
let slice = canvas.get_data();
455460
let temp_buf = device
456461
.create_buffer_mapped(
@@ -506,7 +511,10 @@ impl Memory {
506511
}
507512

508513
impl Debug for Memory {
509-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
514+
fn fmt(
515+
&self,
516+
f: &mut std::fmt::Formatter<'_>,
517+
) -> Result<(), std::fmt::Error> {
510518
match self {
511519
Memory::Host { .. } => write!(f, "Memory::Host"),
512520
Memory::Device { .. } => write!(f, "Memory::Device"),
@@ -593,4 +601,4 @@ struct Instance {
593601
#[derive(Debug, Clone, Copy)]
594602
struct Uniforms {
595603
transform: [f32; 16],
596-
}
604+
}

wgpu/src/text/font.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
pub use font_kit::error::SelectionError as LoadError;
2-
pub use font_kit::family_name::FamilyName as Family;
1+
pub use font_kit::{
2+
error::SelectionError as LoadError, family_name::FamilyName as Family,
3+
};
34

45
pub struct Source {
56
raw: font_kit::source::SystemSource,

0 commit comments

Comments
 (0)