summaryrefslogtreecommitdiffstats
path: root/examples/geometry
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-11-28 19:49:23 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-11-28 19:49:23 +0100
commitbb2bf063b472396d44f9f3114a87ba79dfd5f62e (patch)
tree58072c44539d4b7009fff3defe97834438234b1b /examples/geometry
parent324d60db6319017304bf0b514b76db98b3637929 (diff)
downloadiced-bb2bf063b472396d44f9f3114a87ba79dfd5f62e.tar.gz
iced-bb2bf063b472396d44f9f3114a87ba79dfd5f62e.tar.bz2
iced-bb2bf063b472396d44f9f3114a87ba79dfd5f62e.zip
Derive `Default` for `Rainbow` in `geometry` example
Diffstat (limited to 'examples/geometry')
-rw-r--r--examples/geometry/src/main.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/examples/geometry/src/main.rs b/examples/geometry/src/main.rs
index 4de281fe..9bacce7f 100644
--- a/examples/geometry/src/main.rs
+++ b/examples/geometry/src/main.rs
@@ -20,12 +20,11 @@ mod rainbow {
Element, Layout, Length, Point, Rectangle, Size, Vector,
};
+ #[derive(Debug, Clone, Copy, Default)]
pub struct Rainbow;
- impl Rainbow {
- pub fn new() -> Self {
- Self
- }
+ pub fn rainbow() -> Rainbow {
+ Rainbow
}
impl<Message, B, T> Widget<Message, Renderer<B, T>> for Rainbow
@@ -164,7 +163,7 @@ mod rainbow {
use iced::widget::{column, container, scrollable};
use iced::{Element, Length, Sandbox, Settings};
-use rainbow::Rainbow;
+use rainbow::rainbow;
pub fn main() -> iced::Result {
Example::run(Settings::default())
@@ -187,7 +186,7 @@ impl Sandbox for Example {
fn view(&self) -> Element<()> {
let content = column![
- Rainbow::new(),
+ rainbow(),
"In this example we draw a custom widget Rainbow, using \
the Mesh2D primitive. This primitive supplies a list of \
triangles, expressed as vertices and indices.",