Skip to content

Commit 9d62ab8

Browse files
committed
Fix test workflow by ignoring incomplete Rust code blocks
1 parent 2c648ce commit 9d62ab8

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/first-steps.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ and most idiomatic way to express this logic in Rust is by defining a method nam
6868
For our counter interface, we only need to properly increment or decrement the `value` of our `Counter` struct based on the `Message`
6969
we just defined:
7070

71-
```rust
71+
```rust,ignore
7272
impl Counter {
7373
fn update(&mut self, message: Message) {
7474
match message {
@@ -85,28 +85,28 @@ impl Counter {
8585

8686
Great! Now we are ready to process user interactions. For instance, imagine we initialized our counter like this:
8787

88-
```rust
88+
```rust,ignore
8989
let mut counter = Counter { value: 0 };
9090
```
9191

9292
And let's say we wanted to simulate a user playing with our interface for a bit—pressing the increment button twice
9393
and then the decrement button once. We could easily compute the final state of our counter with our __update logic__:
9494

95-
```rust
95+
```rust,ignore
9696
counter.update(Message::Increment);
9797
counter.update(Message::Increment);
9898
counter.update(Message::Decrement);
9999
```
100100

101101
This would cause our `Counter` to end up with a `value` of `1`:
102102

103-
```rust
103+
```rust,ignore
104104
assert_eq!(counter.value, 1);
105105
```
106106

107107
In fact, we have just written a simple test for our application logic:
108108

109-
```rust
109+
```rust,ignore
110110
#[test]
111111
fn it_counts_properly() {
112112
let mut counter = Counter { value: 0 };
@@ -154,7 +154,7 @@ These values are normally created using a _helper function_ from the `widget` mo
154154

155155
For our buttons, we can use the `button` helper:
156156

157-
```rust
157+
```rust,ignore
158158
use iced::widget::button;
159159
160160
let increment = button("+");
@@ -174,7 +174,7 @@ for our counter value?
174174
While iced does not really have a `number` widget, it does have a more generic `text` widget that can be used
175175
to display any kind of text—numbers included:
176176

177-
```rust
177+
```rust,ignore
178178
use iced::widget::text;
179179
180180
let counter = text(15);
@@ -191,7 +191,7 @@ __six__ different ways to order them! However, the order we want is: `increment`
191191

192192
A very simple way of describing this order is to create a list with our widgets:
193193

194-
```rust
194+
```rust,ignore
195195
let interface = vec![increment, counter, decrement];
196196
```
197197

@@ -205,7 +205,7 @@ manage the position of existing widgets. And since widgets are just values, they
205205

206206
The kind of vertical layout that we need for our counter can be achieved with the `column` widget:
207207

208-
```rust
208+
```rust,ignore
209209
use iced::widget::column;
210210
211211
let interface = column![increment, counter, decrement];
@@ -226,7 +226,7 @@ In iced, every widget has a specific type that enables further configuration usi
226226
helper returns an instance of [the `Button` type], which has an `on_press` method we can use to define the message it must
227227
__produce__ when a user presses the button:
228228

229-
```rust
229+
```rust,ignore
230230
use iced::widget::button;
231231
232232
let increment = button("+").on_press(Message::Increment);
@@ -257,7 +257,7 @@ We are almost there! There is only one thing left to do: connecting our applicat
257257

258258
Let's bring together all the view logic we have written so far:
259259

260-
```rust
260+
```rust,ignore
261261
use iced::widget::{button, column, text};
262262
263263
// The buttons
@@ -280,7 +280,7 @@ our update logic is triggered, the text widget will display the new `value`.
280280

281281
We can easily do this by running our view logic in a method of our `Counter`—just like we did with our update logic:
282282

283-
```rust
283+
```rust,ignore
284284
use iced::widget::{button, column, text};
285285
286286
impl Counter {
@@ -310,7 +310,7 @@ Instead of throwing the `interface` away, we need to return it. Remember, the pu
310310
to dictate the widgets of our user interface; and the content of the `interface` variable is precisely the
311311
description of the interface we want:
312312

313-
```rust
313+
```rust,ignore
314314
use iced::widget::{button, column, text, Column};
315315
316316
impl Counter {
@@ -347,7 +347,7 @@ let's just inline everything:
347347
<img alt="A classical counter interface" src="resources/counter-interface.svg" width="50%">
348348
</div>
349349

350-
```rust
350+
```rust,ignore
351351
use iced::widget::{button, column, text, Column};
352352
353353
impl Counter {

src/the-runtime.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Let's try to get a better understanding of the lifetime of an interface by explo
3636
In fact, we have actually started writing a runtime already! When [we implemented the update logic of our counter](first-steps.md#update-logic),
3737
we wrote a very small test that simulated a user:
3838
39-
```rust
39+
```rust,ignore
4040
#[test]
4141
fn it_counts_properly() {
4242
let mut counter = Counter { value: 0 };
@@ -58,7 +58,7 @@ involved—far from what we actually want. Still, it's a great start! Let's try
5858
### Initializing the State
5959
Our small runtime is already initializing the application state properly:
6060

61-
```rust
61+
```rust,ignore
6262
// Initialize the state
6363
let mut counter = Counter { value: 0 };
6464
```
@@ -74,7 +74,7 @@ struct Counter {
7474

7575
And then, we simply use `Counter::default` in our runtime:
7676

77-
```rust
77+
```rust,ignore
7878
// Initialize the state
7979
let mut counter = Counter::default();
8080
```
@@ -93,7 +93,7 @@ and then render the widgets returned by our __view logic__—properly laid out,
9393
What? You have no clue of how to do that? Don't worry, I have this magical function: `display`. It takes a reference to
9494
any interface and displays it to the user. It totally works!
9595

96-
```rust
96+
```rust,ignore
9797
use magic::display;
9898
9999
# // Initialize the state
@@ -116,7 +116,7 @@ the interactions and produce all the relevant __messages__ that our widgets spec
116116
How? With some more magic, of course! I just found this `interact` function inside of my top hat—it takes an
117117
interface and produces the __messages__ that correspond to the latest interactions of the user.
118118

119-
```rust
119+
```rust,ignore
120120
use magic::{display, interact};
121121
122122
# // Initialize the state
@@ -141,7 +141,7 @@ react properly to the user, we need to update our __state__ accordingly for each
141141

142142
Luckily, there are no more magic tricks involved in this step—we can just use our __update logic__:
143143

144-
```rust
144+
```rust,ignore
145145
# use magic::{display, interact};
146146
#
147147
# // Initialize the state
@@ -171,7 +171,7 @@ And then... Do it all over once again!
171171

172172
This is a loop! And no, loops aren't very magical—not when we write Rust, at least:
173173

174-
```rust
174+
```rust,ignore
175175
use magic::{display, interact};
176176
177177
// Initialize the state
@@ -214,7 +214,7 @@ its own magic[^magic]—so you don't need to worry about learning the dark arts
214214

215215
If we want to run our `Counter`, all we have to do is call [`run`]:
216216

217-
```rust
217+
```rust,ignore
218218
# use iced::widget::{button, column, text, Column};
219219
#
220220
pub fn main() -> iced::Result {

0 commit comments

Comments
 (0)