Skip to content

Commit 94388ad

Browse files
committed
rust helloworld
1 parent 3cd5c70 commit 94388ad

File tree

4 files changed

+158
-0
lines changed

4 files changed

+158
-0
lines changed

.github/workflows/rust.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
name: Rust - CI
3+
4+
on:
5+
push:
6+
paths:
7+
- 'runtime/rust/**'
8+
- '!**/*.md'
9+
branches:
10+
- 'develop'
11+
- 'main'
12+
- 'release/**'
13+
pull_request:
14+
paths:
15+
- 'runtime/rust/**'
16+
- '!**/*.md'
17+
branches:
18+
- 'develop'
19+
- 'main'
20+
- 'release/**'
21+
workflow_dispatch:
22+
23+
env:
24+
CARGO_TERM_COLOR: always
25+
26+
jobs:
27+
build:
28+
29+
runs-on: ubuntu-latest
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Install stable toolchain
35+
uses: actions-rs/toolchain@v1
36+
with:
37+
profile: minimal
38+
toolchain: stable
39+
override: true
40+
41+
- name: Build
42+
uses: actions-rs/cargo@v1
43+
with:
44+
command: build
45+
args: --all-features
46+
47+
- name: Run tests
48+
uses: actions-rs/cargo@v1
49+
with:
50+
command: test
51+
args: --all-features
52+
53+
- name: Run clippy
54+
uses: actions-rs/cargo@v1
55+
with:
56+
command: clippy
57+
args: --all-features -- -D warnings
58+
59+
- name: Run fmt
60+
uses: actions-rs/cargo@v1
61+
with:
62+
command: fmt
63+
args: --all -- --check

runtime/rust/Cargo.lock

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runtime/rust/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "hello-world"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
regex = "1.0"

runtime/rust/src/main.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
use regex::Regex;
2+
3+
fn main() {
4+
println!("Hello, world!");
5+
6+
// Example usage of the regex crate
7+
let re = Regex::new(r"^Hello, (.+)!$").unwrap();
8+
let text = "Hello, world!";
9+
if let Some(caps) = re.captures(text) {
10+
println!("Greeting target: {}", &caps[1]);
11+
}
12+
}
13+
14+
#[cfg(test)]
15+
mod tests {
16+
use super::*;
17+
18+
#[test]
19+
fn it_prints_hello_world() {
20+
// Capture output if needed, but for now, we'll just assert a simple condition
21+
assert_eq!(2 + 2, 4);
22+
}
23+
24+
#[test]
25+
fn it_works_with_regex() {
26+
let re = Regex::new(r"^Hello, (.+)!$").unwrap();
27+
let text = "Hello, world!";
28+
assert!(re.is_match(text));
29+
30+
if let Some(caps) = re.captures(text) {
31+
assert_eq!(&caps[1], "world");
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)