summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-07-09 18:42:41 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-07-09 18:43:05 +0200
commit2065a40f642589134142a740ff4198deaa4c378b (patch)
tree00477d6d7cb571332062535557151d5b031d8925 /examples
parentd53cc5498b92fb6b573867f5ccb5f8ac93f6be79 (diff)
downloadiced-2065a40f642589134142a740ff4198deaa4c378b.tar.gz
iced-2065a40f642589134142a740ff4198deaa4c378b.tar.bz2
iced-2065a40f642589134142a740ff4198deaa4c378b.zip
Fix `clippy` lints for all crates and features
... and check those in CI as well!
Diffstat (limited to 'examples')
-rw-r--r--examples/color_palette/src/main.rs2
-rw-r--r--examples/component/src/main.rs3
-rw-r--r--examples/custom_widget/src/main.rs6
-rw-r--r--examples/download_progress/src/main.rs9
-rw-r--r--examples/game_of_life/src/main.rs10
-rw-r--r--examples/game_of_life/src/preset.rs10
-rw-r--r--examples/geometry/src/main.rs7
-rw-r--r--examples/integration_opengl/src/main.rs5
-rw-r--r--examples/integration_wgpu/src/controls.rs2
-rw-r--r--examples/integration_wgpu/src/main.rs10
-rw-r--r--examples/integration_wgpu/src/scene.rs69
-rw-r--r--examples/pokedex/src/main.rs3
-rw-r--r--examples/pure/component/src/main.rs3
-rw-r--r--examples/pure/game_of_life/src/main.rs2
-rw-r--r--examples/pure/game_of_life/src/preset.rs10
-rw-r--r--examples/pure/todos/src/main.rs28
-rw-r--r--examples/pure/tour/src/main.rs10
-rw-r--r--examples/solar_system/src/main.rs3
-rw-r--r--examples/stopwatch/src/main.rs7
-rw-r--r--examples/system_information/src/main.rs7
-rw-r--r--examples/todos/src/main.rs28
-rw-r--r--examples/tooltip/src/main.rs17
-rw-r--r--examples/url_handler/src/main.rs2
-rw-r--r--examples/websocket/src/echo.rs6
-rw-r--r--examples/websocket/src/echo/server.rs8
25 files changed, 121 insertions, 146 deletions
diff --git a/examples/color_palette/src/main.rs b/examples/color_palette/src/main.rs
index 16c87a75..cc1af750 100644
--- a/examples/color_palette/src/main.rs
+++ b/examples/color_palette/src/main.rs
@@ -84,7 +84,7 @@ impl Sandbox for ColorPalette {
}
#[derive(Debug)]
-pub struct Theme {
+struct Theme {
lower: Vec<Color>,
base: Color,
higher: Vec<Color>,
diff --git a/examples/component/src/main.rs b/examples/component/src/main.rs
index b6ff0600..6a8f53e2 100644
--- a/examples/component/src/main.rs
+++ b/examples/component/src/main.rs
@@ -150,8 +150,7 @@ mod numeric_input {
self.value
.as_ref()
.map(u32::to_string)
- .as_ref()
- .map(String::as_str)
+ .as_deref()
.unwrap_or(""),
Event::InputChanged,
)
diff --git a/examples/custom_widget/src/main.rs b/examples/custom_widget/src/main.rs
index ce5306ba..d1a7bb06 100644
--- a/examples/custom_widget/src/main.rs
+++ b/examples/custom_widget/src/main.rs
@@ -64,12 +64,12 @@ mod circle {
}
}
- impl<'a, Message, Renderer> Into<Element<'a, Message, Renderer>> for Circle
+ impl<'a, Message, Renderer> From<Circle> for Element<'a, Message, Renderer>
where
Renderer: renderer::Renderer,
{
- fn into(self) -> Element<'a, Message, Renderer> {
- Element::new(self)
+ fn from(circle: Circle) -> Self {
+ Self::new(circle)
}
}
}
diff --git a/examples/download_progress/src/main.rs b/examples/download_progress/src/main.rs
index 4a801ba4..2999bc7e 100644
--- a/examples/download_progress/src/main.rs
+++ b/examples/download_progress/src/main.rs
@@ -49,7 +49,7 @@ impl Application for Example {
fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::Add => {
- self.last_id = self.last_id + 1;
+ self.last_id += 1;
self.downloads.push(Download::new(self.last_id));
}
@@ -134,8 +134,8 @@ impl Download {
}
pub fn progress(&mut self, new_progress: download::Progress) {
- match &mut self.state {
- State::Downloading { progress } => match new_progress {
+ if let State::Downloading { progress } = &mut self.state {
+ match new_progress {
download::Progress::Started => {
*progress = 0.0;
}
@@ -152,8 +152,7 @@ impl Download {
button: button::State::new(),
};
}
- },
- _ => {}
+ }
}
}
diff --git a/examples/game_of_life/src/main.rs b/examples/game_of_life/src/main.rs
index 35399584..62ecc2d1 100644
--- a/examples/game_of_life/src/main.rs
+++ b/examples/game_of_life/src/main.rs
@@ -280,7 +280,7 @@ mod grid {
}
}
- pub fn view<'a>(&'a mut self) -> Element<'a, Message> {
+ pub fn view(&mut self) -> Element<Message> {
Canvas::new(self)
.width(Length::Fill)
.height(Length::Fill)
@@ -328,7 +328,7 @@ mod grid {
}
}
- impl<'a> canvas::Program<Message> for Grid {
+ impl canvas::Program<Message> for Grid {
fn update(
&mut self,
event: Event,
@@ -826,13 +826,13 @@ struct Controls {
}
impl Controls {
- fn view<'a>(
- &'a mut self,
+ fn view(
+ &mut self,
is_playing: bool,
is_grid_enabled: bool,
speed: usize,
preset: Preset,
- ) -> Element<'a, Message> {
+ ) -> Element<Message> {
let playback_controls = Row::new()
.spacing(10)
.push(
diff --git a/examples/game_of_life/src/preset.rs b/examples/game_of_life/src/preset.rs
index 05157b6a..964b9120 100644
--- a/examples/game_of_life/src/preset.rs
+++ b/examples/game_of_life/src/preset.rs
@@ -1,7 +1,7 @@
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Preset {
Custom,
- XKCD,
+ Xkcd,
Glider,
SmallExploder,
Exploder,
@@ -14,7 +14,7 @@ pub enum Preset {
pub static ALL: &[Preset] = &[
Preset::Custom,
- Preset::XKCD,
+ Preset::Xkcd,
Preset::Glider,
Preset::SmallExploder,
Preset::Exploder,
@@ -30,7 +30,7 @@ impl Preset {
#[rustfmt::skip]
let cells = match self {
Preset::Custom => vec![],
- Preset::XKCD => vec![
+ Preset::Xkcd => vec![
" xxx ",
" x x ",
" x x ",
@@ -116,7 +116,7 @@ impl Preset {
impl Default for Preset {
fn default() -> Preset {
- Preset::XKCD
+ Preset::Xkcd
}
}
@@ -127,7 +127,7 @@ impl std::fmt::Display for Preset {
"{}",
match self {
Preset::Custom => "Custom",
- Preset::XKCD => "xkcd #2293",
+ Preset::Xkcd => "xkcd #2293",
Preset::Glider => "Glider",
Preset::SmallExploder => "Small Exploder",
Preset::Exploder => "Exploder",
diff --git a/examples/geometry/src/main.rs b/examples/geometry/src/main.rs
index ba4b808e..03eac69e 100644
--- a/examples/geometry/src/main.rs
+++ b/examples/geometry/src/main.rs
@@ -17,6 +17,7 @@ mod rainbow {
layout, Element, Layout, Length, Point, Rectangle, Size, Vector, Widget,
};
+ #[derive(Default)]
pub struct Rainbow;
impl Rainbow {
@@ -148,12 +149,12 @@ mod rainbow {
}
}
- impl<'a, Message, B, T> Into<Element<'a, Message, Renderer<B, T>>> for Rainbow
+ impl<'a, Message, B, T> From<Rainbow> for Element<'a, Message, Renderer<B, T>>
where
B: Backend,
{
- fn into(self) -> Element<'a, Message, Renderer<B, T>> {
- Element::new(self)
+ fn from(rainbow: Rainbow) -> Self {
+ Self::new(rainbow)
}
}
}
diff --git a/examples/integration_opengl/src/main.rs b/examples/integration_opengl/src/main.rs
index 1a78a493..f161c8a0 100644
--- a/examples/integration_opengl/src/main.rs
+++ b/examples/integration_opengl/src/main.rs
@@ -58,7 +58,7 @@ pub fn main() {
let mut cursor_position = PhysicalPosition::new(-1.0, -1.0);
let mut modifiers = ModifiersState::default();
- let mut clipboard = Clipboard::connect(&windowed_context.window());
+ let mut clipboard = Clipboard::connect(windowed_context.window());
let mut renderer = Renderer::new(Backend::new(&gl, Settings::default()));
@@ -73,13 +73,12 @@ pub fn main() {
);
let mut resized = false;
- let scene = Scene::new(&gl, &shader_version);
+ let scene = Scene::new(&gl, shader_version);
event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait;
match event {
- Event::LoopDestroyed => return,
Event::WindowEvent { event, .. } => {
match event {
WindowEvent::CursorMoved { position, .. } => {
diff --git a/examples/integration_wgpu/src/controls.rs b/examples/integration_wgpu/src/controls.rs
index cb2c423f..2f1daa91 100644
--- a/examples/integration_wgpu/src/controls.rs
+++ b/examples/integration_wgpu/src/controls.rs
@@ -112,7 +112,7 @@ impl Program for Controls {
t,
"Placeholder",
text,
- move |text| Message::TextChanged(text),
+ Message::TextChanged,
)),
),
)
diff --git a/examples/integration_wgpu/src/main.rs b/examples/integration_wgpu/src/main.rs
index 3d27a0f0..86a0d6a4 100644
--- a/examples/integration_wgpu/src/main.rs
+++ b/examples/integration_wgpu/src/main.rs
@@ -73,7 +73,7 @@ pub fn main() {
let instance = wgpu::Instance::new(backend);
let surface = unsafe { instance.create_surface(&window) };
- let (format, (mut device, queue)) = futures::executor::block_on(async {
+ let (format, (device, queue)) = futures::executor::block_on(async {
let adapter = wgpu::util::initialize_adapter_from_env_or_default(
&instance,
backend,
@@ -128,13 +128,13 @@ pub fn main() {
let mut staging_belt = wgpu::util::StagingBelt::new(5 * 1024);
// Initialize scene and GUI controls
- let scene = Scene::new(&mut device, format);
+ let scene = Scene::new(&device, format);
let controls = Controls::new();
// Initialize iced
let mut debug = Debug::new();
let mut renderer =
- Renderer::new(Backend::new(&mut device, Settings::default(), format));
+ Renderer::new(Backend::new(&device, Settings::default(), format));
let mut state = program::State::new(
controls,
@@ -208,8 +208,8 @@ pub fn main() {
surface.configure(
&device,
&wgpu::SurfaceConfiguration {
+ format,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
- format: format,
width: size.width,
height: size.height,
present_mode: wgpu::PresentMode::AutoVsync,
@@ -244,7 +244,7 @@ pub fn main() {
// And then iced on top
renderer.with_primitives(|backend, primitive| {
backend.present(
- &mut device,
+ &device,
&mut staging_belt,
&mut encoder,
&view,
diff --git a/examples/integration_wgpu/src/scene.rs b/examples/integration_wgpu/src/scene.rs
index af75e67c..3e41fbda 100644
--- a/examples/integration_wgpu/src/scene.rs
+++ b/examples/integration_wgpu/src/scene.rs
@@ -66,40 +66,37 @@ fn build_pipeline(
bind_group_layouts: &[],
});
- let pipeline =
- device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
- label: None,
- layout: Some(&pipeline_layout),
- vertex: wgpu::VertexState {
- module: &vs_module,
- entry_point: "main",
- buffers: &[],
- },
- fragment: Some(wgpu::FragmentState {
- module: &fs_module,
- entry_point: "main",
- targets: &[Some(wgpu::ColorTargetState {
- format: texture_format,
- blend: Some(wgpu::BlendState {
- color: wgpu::BlendComponent::REPLACE,
- alpha: wgpu::BlendComponent::REPLACE,
- }),
- write_mask: wgpu::ColorWrites::ALL,
- })],
- }),
- primitive: wgpu::PrimitiveState {
- topology: wgpu::PrimitiveTopology::TriangleList,
- front_face: wgpu::FrontFace::Ccw,
- ..Default::default()
- },
- depth_stencil: None,
- multisample: wgpu::MultisampleState {
- count: 1,
- mask: !0,
- alpha_to_coverage_enabled: false,
- },
- multiview: None,
- });
-
- pipeline
+ device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
+ label: None,
+ layout: Some(&pipeline_layout),
+ vertex: wgpu::VertexState {
+ module: &vs_module,
+ entry_point: "main",
+ buffers: &[],
+ },
+ fragment: Some(wgpu::FragmentState {
+ module: &fs_module,
+ entry_point: "main",
+ targets: &[Some(wgpu::ColorTargetState {
+ format: texture_format,
+ blend: Some(wgpu::BlendState {
+ color: wgpu::BlendComponent::REPLACE,
+ alpha: wgpu::BlendComponent::REPLACE,
+ }),
+ write_mask: wgpu::ColorWrites::ALL,
+ })],
+ }),
+ primitive: wgpu::PrimitiveState {
+ topology: wgpu::PrimitiveTopology::TriangleList,
+ front_face: wgpu::FrontFace::Ccw,
+ ..Default::default()
+ },
+ depth_stencil: None,
+ multisample: wgpu::MultisampleState {
+ count: 1,
+ mask: !0,
+ alpha_to_coverage_enabled: false,
+ },
+ multiview: None,
+ })
}
diff --git a/examples/pokedex/src/main.rs b/examples/pokedex/src/main.rs
index 89d865e4..a1cf68e8 100644
--- a/examples/pokedex/src/main.rs
+++ b/examples/pokedex/src/main.rs
@@ -192,8 +192,7 @@ impl Pokemon {
let description = entry
.flavor_text_entries
.iter()
- .filter(|text| text.language.name == "en")
- .next()
+ .find(|text| text.language.name == "en")
.ok_or(Error::LanguageError)?;
Ok(Pokemon {
diff --git a/examples/pure/component/src/main.rs b/examples/pure/component/src/main.rs
index 64935afd..db22d019 100644
--- a/examples/pure/component/src/main.rs
+++ b/examples/pure/component/src/main.rs
@@ -143,8 +143,7 @@ mod numeric_input {
self.value
.as_ref()
.map(u32::to_string)
- .as_ref()
- .map(String::as_str)
+ .as_deref()
.unwrap_or(""),
Event::InputChanged,
)
diff --git a/examples/pure/game_of_life/src/main.rs b/examples/pure/game_of_life/src/main.rs
index 851fbd47..cf6560d6 100644
--- a/examples/pure/game_of_life/src/main.rs
+++ b/examples/pure/game_of_life/src/main.rs
@@ -350,7 +350,7 @@ mod grid {
}
}
- pub fn view<'a>(&'a self) -> Element<'a, Message> {
+ pub fn view(&self) -> Element<Message> {
Canvas::new(self)
.width(Length::Fill)
.height(Length::Fill)
diff --git a/examples/pure/game_of_life/src/preset.rs b/examples/pure/game_of_life/src/preset.rs
index 05157b6a..964b9120 100644
--- a/examples/pure/game_of_life/src/preset.rs
+++ b/examples/pure/game_of_life/src/preset.rs
@@ -1,7 +1,7 @@
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Preset {
Custom,
- XKCD,
+ Xkcd,
Glider,
SmallExploder,
Exploder,
@@ -14,7 +14,7 @@ pub enum Preset {
pub static ALL: &[Preset] = &[
Preset::Custom,
- Preset::XKCD,
+ Preset::Xkcd,
Preset::Glider,
Preset::SmallExploder,
Preset::Exploder,
@@ -30,7 +30,7 @@ impl Preset {
#[rustfmt::skip]
let cells = match self {
Preset::Custom => vec![],
- Preset::XKCD => vec![
+ Preset::Xkcd => vec![
" xxx ",
" x x ",
" x x ",
@@ -116,7 +116,7 @@ impl Preset {
impl Default for Preset {
fn default() -> Preset {
- Preset::XKCD
+ Preset::Xkcd
}
}
@@ -127,7 +127,7 @@ impl std::fmt::Display for Preset {
"{}",
match self {
Preset::Custom => "Custom",
- Preset::XKCD => "xkcd #2293",
+ Preset::Xkcd => "xkcd #2293",
Preset::Glider => "Glider",
Preset::SmallExploder => "Small Exploder",
Preset::Exploder => "Exploder",
diff --git a/examples/pure/todos/src/main.rs b/examples/pure/todos/src/main.rs
index 723386ad..c2313035 100644
--- a/examples/pure/todos/src/main.rs
+++ b/examples/pure/todos/src/main.rs
@@ -167,7 +167,7 @@ impl Application for Todos {
.size(30)
.on_submit(Message::CreateTask);
- let controls = view_controls(&tasks, *filter);
+ let controls = view_controls(tasks, *filter);
let filtered_tasks =
tasks.iter().filter(|task| filter.matches(task));
@@ -446,15 +446,15 @@ struct SavedState {
#[derive(Debug, Clone)]
enum LoadError {
- FileError,
- FormatError,
+ File,
+ Format,
}
#[derive(Debug, Clone)]
enum SaveError {
- FileError,
- WriteError,
- FormatError,
+ File,
+ Write,
+ Format,
}
#[cfg(not(target_arch = "wasm32"))]
@@ -465,7 +465,7 @@ impl SavedState {
{
project_dirs.data_dir().into()
} else {
- std::env::current_dir().unwrap_or(std::path::PathBuf::new())
+ std::env::current_dir().unwrap_or_default()
};
path.push("todos.json");
@@ -480,37 +480,37 @@ impl SavedState {
let mut file = async_std::fs::File::open(Self::path())
.await
- .map_err(|_| LoadError::FileError)?;
+ .map_err(|_| LoadError::File)?;
file.read_to_string(&mut contents)
.await
- .map_err(|_| LoadError::FileError)?;
+ .map_err(|_| LoadError::File)?;
- serde_json::from_str(&contents).map_err(|_| LoadError::FormatError)
+ serde_json::from_str(&contents).map_err(|_| LoadError::Format)
}
async fn save(self) -> Result<(), SaveError> {
use async_std::prelude::*;
let json = serde_json::to_string_pretty(&self)
- .map_err(|_| SaveError::FormatError)?;
+ .map_err(|_| SaveError::Format)?;
let path = Self::path();
if let Some(dir) = path.parent() {
async_std::fs::create_dir_all(dir)
.await
- .map_err(|_| SaveError::FileError)?;
+ .map_err(|_| SaveError::File)?;
}
{
let mut file = async_std::fs::File::create(path)
.await
- .map_err(|_| SaveError::FileError)?;
+ .map_err(|_| SaveError::File)?;
file.write_all(json.as_bytes())
.await
- .map_err(|_| SaveError::WriteError)?;
+ .map_err(|_| SaveError::Write)?;
}
// This is a simple way to save at most once every couple seconds
diff --git a/examples/pure/tour/src/main.rs b/examples/pure/tour/src/main.rs
index 477a1ec7..05c269c3 100644
--- a/examples/pure/tour/src/main.rs
+++ b/examples/pure/tour/src/main.rs
@@ -78,14 +78,6 @@ impl Sandbox for Tour {
.push(controls)
.into();
- let content = if self.debug {
- // TODO
- //content.explain(Color::BLACK)
- content
- } else {
- content
- };
-
let scrollable =
scrollable(container(content).width(Length::Fill).center_x());
@@ -494,7 +486,7 @@ impl<'a> Step {
.push(ferris(width))
.push(slider(100..=500, width, StepMessage::ImageWidthChanged))
.push(
- text(format!("Width: {} px", width.to_string()))
+ text(format!("Width: {} px", width))
.width(Length::Fill)
.horizontal_alignment(alignment::Horizontal::Center),
)
diff --git a/examples/solar_system/src/main.rs b/examples/solar_system/src/main.rs
index cee9a02f..fc53d8f7 100644
--- a/examples/solar_system/src/main.rs
+++ b/examples/solar_system/src/main.rs
@@ -65,8 +65,7 @@ impl Application for SolarSystem {
}
fn subscription(&self) -> Subscription<Message> {
- time::every(std::time::Duration::from_millis(10))
- .map(|instant| Message::Tick(instant))
+ time::every(std::time::Duration::from_millis(10)).map(Message::Tick)
}
fn view(&mut self) -> Element<Message> {
diff --git a/examples/stopwatch/src/main.rs b/examples/stopwatch/src/main.rs
index b83b92ec..b7c816ff 100644
--- a/examples/stopwatch/src/main.rs
+++ b/examples/stopwatch/src/main.rs
@@ -67,13 +67,12 @@ impl Application for Stopwatch {
self.state = State::Idle;
}
},
- Message::Tick(now) => match &mut self.state {
- State::Ticking { last_tick } => {
+ Message::Tick(now) => {
+ if let State::Ticking { last_tick } = &mut self.state {
self.duration += now - *last_tick;
*last_tick = now;
}
- _ => {}
- },
+ }
Message::Reset => {
self.duration = Duration::default();
}
diff --git a/examples/system_information/src/main.rs b/examples/system_information/src/main.rs
index 9e6a2f61..54fc635f 100644
--- a/examples/system_information/src/main.rs
+++ b/examples/system_information/src/main.rs
@@ -107,11 +107,8 @@ impl Application for Example {
ByteSize::kb(information.memory_total).to_string();
let memory_total = Text::new(format!(
- "Memory (total): {}",
- format!(
- "{} kb ({})",
- information.memory_total, memory_readable
- )
+ "Memory (total): {} kb ({})",
+ information.memory_total, memory_readable
));
let memory_text = if let Some(memory_used) =
diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs
index dc080ef5..7bfc2a34 100644
--- a/examples/todos/src/main.rs
+++ b/examples/todos/src/main.rs
@@ -168,7 +168,7 @@ impl Application for Todos {
.size(30)
.on_submit(Message::CreateTask);
- let controls = controls.view(&tasks, *filter);
+ let controls = controls.view(tasks, *filter);
let filtered_tasks =
tasks.iter().filter(|task| filter.matches(task));
@@ -493,15 +493,15 @@ struct SavedState {
#[derive(Debug, Clone)]
enum LoadError {
- FileError,
- FormatError,
+ File,
+ Format,
}
#[derive(Debug, Clone)]
enum SaveError {
- FileError,
- WriteError,
- FormatError,
+ File,
+ Write,
+ Format,
}
#[cfg(not(target_arch = "wasm32"))]
@@ -512,7 +512,7 @@ impl SavedState {
{
project_dirs.data_dir().into()
} else {
- std::env::current_dir().unwrap_or(std::path::PathBuf::new())
+ std::env::current_dir().unwrap_or_default()
};
path.push("todos.json");
@@ -527,37 +527,37 @@ impl SavedState {
let mut file = async_std::fs::File::open(Self::path())
.await
- .map_err(|_| LoadError::FileError)?;
+ .map_err(|_| LoadError::File)?;
file.read_to_string(&mut contents)
.await
- .map_err(|_| LoadError::FileError)?;
+ .map_err(|_| LoadError::File)?;
- serde_json::from_str(&contents).map_err(|_| LoadError::FormatError)
+ serde_json::from_str(&contents).map_err(|_| LoadError::Format)
}
async fn save(self) -> Result<(), SaveError> {
use async_std::prelude::*;
let json = serde_json::to_string_pretty(&self)
- .map_err(|_| SaveError::FormatError)?;
+ .map_err(|_| SaveError::Format)?;
let path = Self::path();
if let Some(dir) = path.parent() {
async_std::fs::create_dir_all(dir)
.await
- .map_err(|_| SaveError::FileError)?;
+ .map_err(|_| SaveError::File)?;
}
{
let mut file = async_std::fs::File::create(path)
.await
- .map_err(|_| SaveError::FileError)?;
+ .map_err(|_| SaveError::File)?;
file.write_all(json.as_bytes())
.await
- .map_err(|_| SaveError::WriteError)?;
+ .map_err(|_| SaveError::Write)?;
}
// This is a simple way to save at most once every couple seconds
diff --git a/examples/tooltip/src/main.rs b/examples/tooltip/src/main.rs
index 1bd1133c..7c800112 100644
--- a/examples/tooltip/src/main.rs
+++ b/examples/tooltip/src/main.rs
@@ -54,16 +54,11 @@ impl Sandbox for Example {
tooltip::Position::Right,
);
- let fixed_tooltips = Row::with_children(vec![
- top.into(),
- bottom.into(),
- left.into(),
- right.into(),
- ])
- .width(Length::Fill)
- .height(Length::Fill)
- .align_items(Alignment::Center)
- .spacing(50);
+ let fixed_tooltips = Row::with_children(vec![top, bottom, left, right])
+ .width(Length::Fill)
+ .height(Length::Fill)
+ .align_items(Alignment::Center)
+ .spacing(50);
let follow_cursor = tooltip(
"Tooltip follows cursor",
@@ -78,7 +73,7 @@ impl Sandbox for Example {
.center_x()
.center_y()
.into(),
- follow_cursor.into(),
+ follow_cursor,
])
.width(Length::Fill)
.height(Length::Fill)
diff --git a/examples/url_handler/src/main.rs b/examples/url_handler/src/main.rs
index b544c30d..3695b6b7 100644
--- a/examples/url_handler/src/main.rs
+++ b/examples/url_handler/src/main.rs
@@ -57,7 +57,7 @@ impl Application for App {
fn view(&mut self) -> Element<Message> {
let content = match &self.url {
- Some(url) => Text::new(format!("{}", url)),
+ Some(url) => Text::new(url),
None => Text::new("No URL received yet!"),
};
diff --git a/examples/websocket/src/echo.rs b/examples/websocket/src/echo.rs
index 13596ddd..88321880 100644
--- a/examples/websocket/src/echo.rs
+++ b/examples/websocket/src/echo.rs
@@ -32,7 +32,7 @@ pub fn connect() -> Subscription<Event> {
)
}
Err(_) => {
- let _ = tokio::time::sleep(
+ tokio::time::sleep(
tokio::time::Duration::from_secs(1),
)
.await;
@@ -79,6 +79,7 @@ pub fn connect() -> Subscription<Event> {
}
#[derive(Debug)]
+#[allow(clippy::large_enum_variant)]
enum State {
Disconnected,
Connected(
@@ -101,8 +102,7 @@ pub struct Connection(mpsc::Sender<Message>);
impl Connection {
pub fn send(&mut self, message: Message) {
- let _ = self
- .0
+ self.0
.try_send(message)
.expect("Send message to echo server");
}
diff --git a/examples/websocket/src/echo/server.rs b/examples/websocket/src/echo/server.rs
index 7702d417..fef89a12 100644
--- a/examples/websocket/src/echo/server.rs
+++ b/examples/websocket/src/echo/server.rs
@@ -27,9 +27,9 @@ use warp::Filter;
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
pub async fn run() {
- let routes = warp::path::end().and(warp::ws()).map(|ws: warp::ws::Ws| {
- ws.on_upgrade(move |socket| user_connected(socket))
- });
+ let routes = warp::path::end()
+ .and(warp::ws())
+ .map(|ws: warp::ws::Ws| ws.on_upgrade(user_connected));
warp::serve(routes).run(([127, 0, 0, 1], 3030)).await;
}
@@ -40,7 +40,7 @@ async fn user_connected(ws: WebSocket) {
tokio::task::spawn(async move {
while let Some(message) = rx.next().await {
- let _ = user_ws_tx.send(message).await.unwrap_or_else(|e| {
+ user_ws_tx.send(message).await.unwrap_or_else(|e| {
eprintln!("websocket send error: {}", e);
});
}