(base) bordeaux80 :: Persos/Rust/skycrapers ‹master*› » cargo run
warning: skycrapers v0.1.0 (/home/laurent/Documents/Programmation/Projets/Persos/Rust/skycrapers) ignoring invalid dependency `rfs` which is missing a lib target
Compiling skycrapers v0.1.0 (/home/laurent/Documents/Programmation/Projets/Persos/Rust/skycrapers)
error[E0277]: the trait bound `Element<'_, _, _, _>: From` is not satisfied
--> src/main.rs:145:20
|
145 | button(t!("ui.toolbar.new_game").to_string()).on_press(Mess...
| ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
| |
| required by a bound introduced by this call
|
= help: the trait `From` is not implemented for `iced_core::element::Element<'_, _, _, _>`
= help: the following other types implement trait `From`:
`iced_core::element::Element<'_, Link, Theme, Renderer>` implements `From>`
`iced_core::element::Element<'_, Message, Theme, Renderer>` implements `From<&str>`
`iced_core::element::Element<'_, Message, Theme, Renderer>` implements `From>`
`iced_core::element::Element<'_, Message, Theme, Renderer>` implements `From>`
`iced_core::element::Element<'_, Message, Theme, Renderer>` implements `From>`
`iced_core::element::Element<'_, Message, Theme, Renderer>` implements `From>`
`iced_core::element::Element<'_, Message, Theme, Renderer>` implements `From>`
`iced_core::element::Element<'_, Message, Theme, Renderer>` implements `From>`
and 21 others
= note: required for `String` to implement `Into>`
note: required by a bound in `button`
--> /home/laurent/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/iced_widget-0.13.4/src/helpers.rs:835:19
|
834 | pub fn button<'a, Message, Theme, Renderer>(
| ------ required by a bound in this function
835 | content: impl Into>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `button`
= note: the full name for the type has been written to '/home/laurent/Documents/Programmation/Projets/Persos/Rust/skycrapers/target/debug/deps/skycrapers-1975347835c32067.long-type-12169297398742323190.txt'
= note: consider using `--verbose` to print the full type name to the console
help: consider removing this method call, as the receiver has type `Cow<'_, str>` and `Cow<'_, str>: From` trivially holds
|
14 - i18n!("locales", fallback = "en");
15 - use rust_i18n::t;
16 -
17 - const CELLS_SIZE: f32 = 40.0;
18 -
19 - fn main() -> iced::Result {
20 - iced::run("Skycrapers", MyApp::update, MyApp::view)
21 - }
22 -
23 - #[derive(Debug, Clone)]
24 - enum Message {
25 - Update(u8, u8, String),
26 - NewGame,
27 - Check,
28 - }
29 -
30 - struct MyApp {
31 - size: u8,
32 - values: Vec>,
33 - answer: Vec>,
34 - /*
35 - index 0 is the top line
36 - index 1 is the bottom line
37 - index 2 is the left line
38 - index 3 is the right line
39 - */
40 - clues: Vec>,
41 - errors: Vec<(u8, u8)>,
42 - }
43 -
44 - impl MyApp {
45 - fn build_clue_component(&'_ self, clue: u8) -> Text<'_> {
46 - text(format!(
47 - "{}",
48 - if clue != 0 {
49 - clue.to_string()
50 - } else {
51 - String::new()
52 - }
53 - ))
54 - .width(CELLS_SIZE)
55 - .size(CELLS_SIZE)
56 - .align_x(Horizontal::Center)
57 - }
58 -
59 - fn build_empty_clue_component(&'_ self) -> Text<'_> {
60 - text("")
61 - .width(CELLS_SIZE)
62 - .size(CELLS_SIZE)
63 - .align_x(Horizontal::Center)
64 - }
65 -
66 - fn clear_cells(&'_ mut self) {
67 - let mut dyn_array = Vec::new();
68 - for _row in 0..self.size {
69 - let mut col_array = Vec::new();
70 - for _col in 0..self.size {
71 - col_array.push("".to_string());
72 - }
73 - dyn_array.push(col_array);
74 - }
75 - self.values = dyn_array;
76 - }
77 -
78 - fn build_grid_comp(&'_ self) -> Column<'_, Message> {
79 - let mut col_comp = Column::new();
80 -
81 - let mut top_clues = Row::new();
82 - top_clues = top_clues.push(self.build_empty_clue_component());
83 - for col_index in 0..self.size {
84 - let clue_comp = self.build_clue_component(self.clues[0][col_index as usize]);
85 - top_clues = top_clues.push(clue_comp);
86 - }
87 - col_comp = col_comp.push(top_clues);
88 -
89 - for row_index in 0..self.size {
90 - let mut row_comp = Row::new();
91 -
92 - let left_clue_comp = self.build_clue_component(self.clues[2][row_index as usize]);
93 - let right_clue_comp = self.build_clue_component(self.clues[3][row_index as usize]);
94 -
95 - row_comp = row_comp.push(left_clue_comp);
96 -
97 - for col_index in 0..self.size {
98 - let is_error = self.errors.contains(&(row_index, col_index));
99 - let cell = text_input(
100 - "",
101 - self.values[row_index as usize][col_index as usize].as_str(),
102 - )
103 - .width(CELLS_SIZE)
104 - .size(CELLS_SIZE * 0.8)
105 - .align_x(Horizontal::Center)
106 - .style(move |_, _| text_input::Style {
107 - background: iced::Background::Color(Color::TRANSPARENT),
108 -
109 - border: Border {
110 - color: Color::BLACK,
111 - width: 1.0,
112 - radius: Radius::new(0),
113 - },
114 - icon: Color::TRANSPARENT,
115 - placeholder: Color::TRANSPARENT,
116 - selection: Color::TRANSPARENT,
117 - value: if is_error {
118 - Color::from_rgb(1.0, 0.0, 0.0)
119 - } else {
120 - Color::BLACK
121 - },
122 - })
123 - .on_input(move |value| Message::Update(row_index, col_index, value));
124 - row_comp = row_comp.push(cell);
125 - }
126 -
127 - row_comp = row_comp.push(right_clue_comp);
128 -
129 - col_comp = col_comp.push(row_comp);
130 - }
131 -
132 - let mut bottom_clues = Row::new();
133 - bottom_clues = bottom_clues.push(self.build_empty_clue_component());
134 - for col_index in 0..self.size {
135 - let clue_comp = self.build_clue_component(self.clues[1][col_index as usize]);
136 - bottom_clues = bottom_clues.push(clue_comp);
137 - }
138 - col_comp = col_comp.push(bottom_clues);
139 -
140 - col_comp
141 - }
142 -
143 - fn build_toolbar_comp(&self) -> Row<'_, Message> {
144 - let new_game_button =
145 - button(t!("ui.toolbar.new_game").to_string()).on_press(Message::NewGame);
14 + i18n!("locales", fallback = "en")).on_press(Message::NewGame);
|
error[E0277]: the trait bound `Element<'_, _, _, _>: From` is not satisfied
--> src/main.rs:146:35
|
146 | ...k_button = button(t!("ui.toolbar.check").to_string()).on_press(Messa...
| ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
| |
| required by a bound introduced by this call
|
= help: the trait `From` is not implemented for `iced_core::element::Element<'_, _, _, _>`
= help: the following other types implement trait `From`:
`iced_core::element::Element<'_, Link, Theme, Renderer>` implements `From>`
`iced_core::element::Element<'_, Message, Theme, Renderer>` implements `From<&str>`
`iced_core::element::Element<'_, Message, Theme, Renderer>` implements `From>`
`iced_core::element::Element<'_, Message, Theme, Renderer>` implements `From>`
`iced_core::element::Element<'_, Message, Theme, Renderer>` implements `From>`
`iced_core::element::Element<'_, Message, Theme, Renderer>` implements `From>`
`iced_core::element::Element<'_, Message, Theme, Renderer>` implements `From>`
`iced_core::element::Element<'_, Message, Theme, Renderer>` implements `From>`
and 21 others
= note: required for `String` to implement `Into>`
note: required by a bound in `button`
--> /home/laurent/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/iced_widget-0.13.4/src/helpers.rs:835:19
|
834 | pub fn button<'a, Message, Theme, Renderer>(
| ------ required by a bound in this function
835 | content: impl Into>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `button`
= note: the full name for the type has been written to '/home/laurent/Documents/Programmation/Projets/Persos/Rust/skycrapers/target/debug/deps/skycrapers-1975347835c32067.long-type-9008159889769157918.txt'
= note: consider using `--verbose` to print the full type name to the console
help: consider removing this method call, as the receiver has type `Cow<'_, str>` and `Cow<'_, str>: From` trivially holds
|
14 - i18n!("locales", fallback = "en");
15 - use rust_i18n::t;
16 -
17 - const CELLS_SIZE: f32 = 40.0;
18 -
19 - fn main() -> iced::Result {
20 - iced::run("Skycrapers", MyApp::update, MyApp::view)
21 - }
22 -
23 - #[derive(Debug, Clone)]
24 - enum Message {
25 - Update(u8, u8, String),
26 - NewGame,
27 - Check,
28 - }
29 -
30 - struct MyApp {
31 - size: u8,
32 - values: Vec>,
33 - answer: Vec>,
34 - /*
35 - index 0 is the top line
36 - index 1 is the bottom line
37 - index 2 is the left line
38 - index 3 is the right line
39 - */
40 - clues: Vec>,
41 - errors: Vec<(u8, u8)>,
42 - }
43 -
44 - impl MyApp {
45 - fn build_clue_component(&'_ self, clue: u8) -> Text<'_> {
46 - text(format!(
47 - "{}",
48 - if clue != 0 {
49 - clue.to_string()
50 - } else {
51 - String::new()
52 - }
53 - ))
54 - .width(CELLS_SIZE)
55 - .size(CELLS_SIZE)
56 - .align_x(Horizontal::Center)
57 - }
58 -
59 - fn build_empty_clue_component(&'_ self) -> Text<'_> {
60 - text("")
61 - .width(CELLS_SIZE)
62 - .size(CELLS_SIZE)
63 - .align_x(Horizontal::Center)
64 - }
65 -
66 - fn clear_cells(&'_ mut self) {
67 - let mut dyn_array = Vec::new();
68 - for _row in 0..self.size {
69 - let mut col_array = Vec::new();
70 - for _col in 0..self.size {
71 - col_array.push("".to_string());
72 - }
73 - dyn_array.push(col_array);
74 - }
75 - self.values = dyn_array;
76 - }
77 -
78 - fn build_grid_comp(&'_ self) -> Column<'_, Message> {
79 - let mut col_comp = Column::new();
80 -
81 - let mut top_clues = Row::new();
82 - top_clues = top_clues.push(self.build_empty_clue_component());
83 - for col_index in 0..self.size {
84 - let clue_comp = self.build_clue_component(self.clues[0][col_index as usize]);
85 - top_clues = top_clues.push(clue_comp);
86 - }
87 - col_comp = col_comp.push(top_clues);
88 -
89 - for row_index in 0..self.size {
90 - let mut row_comp = Row::new();
91 -
92 - let left_clue_comp = self.build_clue_component(self.clues[2][row_index as usize]);
93 - let right_clue_comp = self.build_clue_component(self.clues[3][row_index as usize]);
94 -
95 - row_comp = row_comp.push(left_clue_comp);
96 -
97 - for col_index in 0..self.size {
98 - let is_error = self.errors.contains(&(row_index, col_index));
99 - let cell = text_input(
100 - "",
101 - self.values[row_index as usize][col_index as usize].as_str(),
102 - )
103 - .width(CELLS_SIZE)
104 - .size(CELLS_SIZE * 0.8)
105 - .align_x(Horizontal::Center)
106 - .style(move |_, _| text_input::Style {
107 - background: iced::Background::Color(Color::TRANSPARENT),
108 -
109 - border: Border {
110 - color: Color::BLACK,
111 - width: 1.0,
112 - radius: Radius::new(0),
113 - },
114 - icon: Color::TRANSPARENT,
115 - placeholder: Color::TRANSPARENT,
116 - selection: Color::TRANSPARENT,
117 - value: if is_error {
118 - Color::from_rgb(1.0, 0.0, 0.0)
119 - } else {
120 - Color::BLACK
121 - },
122 - })
123 - .on_input(move |value| Message::Update(row_index, col_index, value));
124 - row_comp = row_comp.push(cell);
125 - }
126 -
127 - row_comp = row_comp.push(right_clue_comp);
128 -
129 - col_comp = col_comp.push(row_comp);
130 - }
131 -
132 - let mut bottom_clues = Row::new();
133 - bottom_clues = bottom_clues.push(self.build_empty_clue_component());
134 - for col_index in 0..self.size {
135 - let clue_comp = self.build_clue_component(self.clues[1][col_index as usize]);
136 - bottom_clues = bottom_clues.push(clue_comp);
137 - }
138 - col_comp = col_comp.push(bottom_clues);
139 -
140 - col_comp
141 - }
142 -
143 - fn build_toolbar_comp(&self) -> Row<'_, Message> {
144 - let new_game_button =
145 - button(t!("ui.toolbar.new_game").to_string()).on_press(Message::NewGame);
146 - let check_button = button(t!("ui.toolbar.check").to_string()).on_press(Message::Check);
14 + i18n!("locales", fallback = "en")).on_press(Message::Check);
|