Skip to content

Commit d9b2e84

Browse files
authored
Merge pull request #916 from ojeda/match-sample
samples: minimal: match upstream
2 parents eb7a81b + cfa807d commit d9b2e84

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,10 @@ jobs:
270270
grep '] ok 1 - rust_kernel_doctests$' qemu-stdout.log
271271
272272
- run: |
273-
grep '] rust_minimal: Rust minimal sample (init)$' qemu-stdout.log
274-
grep '] rust_minimal: Am I built-in? false$' qemu-stdout.log
275-
grep '] rust_minimal: My message is on the heap!$' qemu-stdout.log
276-
grep '] rust_minimal: Rust minimal sample (exit)$' qemu-stdout.log
273+
grep '] rust_minimal: Rust minimal sample (init)$' qemu-stdout.log
274+
grep '] rust_minimal: Am I built-in? false$' qemu-stdout.log
275+
grep '] rust_minimal: My numbers are \[72, 108, 200]$' qemu-stdout.log
276+
grep '] rust_minimal: Rust minimal sample (exit)$' qemu-stdout.log
277277
278278
- run: |
279279
grep '] rust_print: Rust printing macros sample (init)$' qemu-stdout.log

samples/rust/rust_minimal.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,26 @@ module! {
1313
}
1414

1515
struct RustMinimal {
16-
message: String,
16+
numbers: Vec<i32>,
1717
}
1818

1919
impl kernel::Module for RustMinimal {
2020
fn init(_name: &'static CStr, _module: &'static ThisModule) -> Result<Self> {
2121
pr_info!("Rust minimal sample (init)\n");
2222
pr_info!("Am I built-in? {}\n", !cfg!(MODULE));
2323

24-
Ok(RustMinimal {
25-
message: "on the heap!".try_to_owned()?,
26-
})
24+
let mut numbers = Vec::new();
25+
numbers.try_push(72)?;
26+
numbers.try_push(108)?;
27+
numbers.try_push(200)?;
28+
29+
Ok(RustMinimal { numbers })
2730
}
2831
}
2932

3033
impl Drop for RustMinimal {
3134
fn drop(&mut self) {
32-
pr_info!("My message is {}\n", self.message);
35+
pr_info!("My numbers are {:?}\n", self.numbers);
3336
pr_info!("Rust minimal sample (exit)\n");
3437
}
3538
}

0 commit comments

Comments
 (0)