Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit e19b449

Browse files
committed
chore: example with syntax highlighting
1 parent aae21df commit e19b449

File tree

1 file changed

+15
-42
lines changed

1 file changed

+15
-42
lines changed

examples/demo/src/main.rs

+15-42
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,22 @@
1-
use std::{
2-
fs::File,
3-
io::{self, Write},
4-
process::Command,
5-
};
6-
7-
#[derive(Debug)]
8-
struct Pipe<'a> {
9-
data: &'a str,
10-
ptr: File,
1+
[var]
2+
python! {
3+
print(var)
114
}
125

13-
impl<'a> Pipe<'a> {
14-
fn new(data: &'a str) -> std::io::Result<Self> {
15-
Ok(Pipe {
16-
data,
17-
ptr: File::create("examples/demo/src/pipe.json")?,
18-
})
19-
}
20-
21-
fn send(&mut self) -> io::Result<usize> {
22-
Ok(self.ptr.write(self.data.as_bytes())?)
6+
[one, two, three] -> [scooped]
7+
rust! {
8+
println!("It's A me! mArio!");
9+
let scooped = "RUST STRING";
10+
{
11+
println!("inside block");
2312
}
2413
}
2514

26-
fn main() -> io::Result<()> {
27-
println!("--------------- RUST ---------------");
28-
let mut data = Pipe::new(
29-
r#"
30-
{
31-
"data": "(main.rs) Sent from rust."
15+
[scooped]
16+
c! {
17+
printf("Hello, World!");
18+
{},
19+
printf("%s", scooped);
20+
char* scooped = "C STRING";
3221
}
33-
"#,
34-
)?;
3522

36-
println!("From Rust: {:#?}", data);
37-
println!("Sending...");
38-
data.send()?;
39-
println!("Sent!");
40-
41-
Command::new("python")
42-
.arg("examples/demo/src/pipe.py")
43-
.spawn()
44-
.expect("Couldn't run python. Make Sure you've installed it.");
45-
46-
println!("------------- END RUST -------------");
47-
println!();
48-
Ok(())
49-
}

0 commit comments

Comments
 (0)