From 0245f289b201c8b352dcffcd35e0f0d283085ee2 Mon Sep 17 00:00:00 2001 From: "Ram.Type-0" Date: Mon, 1 Nov 2021 23:41:16 +0900 Subject: Remove unnecessary String allocation Remove unnecessary String allocation by passing &format! or &x.to_string as impl Into --- examples/tour/src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'examples/tour') diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index b5af48c7..c98ecea7 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -417,7 +417,7 @@ impl<'a> Step { StepMessage::SliderChanged, )) .push( - Text::new(&value.to_string()) + Text::new(value.to_string()) .width(Length::Fill) .horizontal_alignment(alignment::Horizontal::Center), ) @@ -464,7 +464,7 @@ impl<'a> Step { StepMessage::SpacingChanged, )) .push( - Text::new(&format!("{} px", spacing)) + Text::new(format!("{} px", spacing)) .width(Length::Fill) .horizontal_alignment(alignment::Horizontal::Center), ); @@ -497,7 +497,7 @@ impl<'a> Step { .spacing(20) .push(Text::new("You can change its size:")) .push( - Text::new(&format!("This text is {} pixels", size)).size(size), + Text::new(format!("This text is {} pixels", size)).size(size), ) .push(Slider::new( size_slider, @@ -518,7 +518,7 @@ impl<'a> Step { .padding(20) .spacing(20) .push(Text::new("And its color:")) - .push(Text::new(&format!("{:?}", color)).color(color)) + .push(Text::new(format!("{:?}", color)).color(color)) .push(color_sliders); Self::container("Text") @@ -589,7 +589,7 @@ impl<'a> Step { StepMessage::ImageWidthChanged, )) .push( - Text::new(&format!("Width: {} px", width.to_string())) + Text::new(format!("Width: {} px", width.to_string())) .width(Length::Fill) .horizontal_alignment(alignment::Horizontal::Center), ) -- cgit From e6627bb96ded028bb6e820965c271430870af629 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 10 Nov 2021 16:35:13 +0700 Subject: Fix formatting with `cargo fmt` --- examples/tour/src/main.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'examples/tour') diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index c98ecea7..b0e87920 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -496,9 +496,7 @@ impl<'a> Step { .padding(20) .spacing(20) .push(Text::new("You can change its size:")) - .push( - Text::new(format!("This text is {} pixels", size)).size(size), - ) + .push(Text::new(format!("This text is {} pixels", size)).size(size)) .push(Slider::new( size_slider, 10..=70, -- cgit