From b4f1aaab7632e769db4679de5642e9d64e832dde Mon Sep 17 00:00:00 2001 From: Federico Rinaldi Date: Sat, 6 Jan 2024 18:07:55 +0100 Subject: [PATCH] Fix clippy (#229) * Add `RenderAssetPersistencePolicy` to `Mesh::new` call * Use built-in `Name` component in `svg` example --- examples/svg.rs | 7 ++----- src/plugin.rs | 10 ++++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/svg.rs b/examples/svg.rs index 27d77b8..00dc6bb 100644 --- a/examples/svg.rs +++ b/examples/svg.rs @@ -11,9 +11,6 @@ fn main() { .run(); } -#[derive(Component)] -struct Name(String); - #[derive(Component)] struct BlacksmithMarker; @@ -25,7 +22,7 @@ fn setup_system(mut commands: Commands) { commands .spawn(( - Name("Blacksmith".to_owned()), + Name::new("Blacksmith"), BlacksmithMarker, SpatialBundle { transform: Transform::from_translation(Vec3::new(-50., 0., 0.)), @@ -62,7 +59,7 @@ fn setup_system(mut commands: Commands) { commands .spawn(( - Name("Shack".to_owned()), + Name::new("Shack"), ToolShackMarker, SpatialBundle { transform: Transform { diff --git a/src/plugin.rs b/src/plugin.rs index 8fab6c0..3765155 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -13,7 +13,10 @@ use bevy::{ prelude::*, - render::{mesh::Indices, render_resource::PrimitiveTopology}, + render::{ + mesh::Indices, render_asset::RenderAssetPersistencePolicy, + render_resource::PrimitiveTopology, + }, sprite::Mesh2dHandle, }; use lyon_tessellation::{self as tess, BuffersBuilder}; @@ -127,7 +130,10 @@ fn stroke( } fn build_mesh(buffers: &VertexBuffers) -> Mesh { - let mut mesh = Mesh::new(PrimitiveTopology::TriangleList); + let mut mesh = Mesh::new( + PrimitiveTopology::TriangleList, + RenderAssetPersistencePolicy::Unload, + ); mesh.set_indices(Some(Indices::U32(buffers.indices.clone()))); mesh.insert_attribute( Mesh::ATTRIBUTE_POSITION,