Skip to content

Commit 5f7d200

Browse files
committed
applied cargo fmt, cleaned project root.
1 parent cfed5b0 commit 5f7d200

5 files changed

Lines changed: 14 additions & 1997 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ Metabuiltins are functions implemented in Rust and exposed to user code. They ha
206206

207207
| Function | Description |
208208
|-------------------------------|-------------------------------------------------------------------|
209-
| `open(path, mode?, content?)` | Open a file. Modes: `r` (read), `w` (write), `a` (append). |
209+
| `open(path, mode, content)` | Open a file. Modes: `r` (read), `w` (write), `a` (append). |
210210

211211
---
212212

examples/hello_io.rpy

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,15 @@ asserteq(5 * 5, 25, "5 * 5 should equal 25");
152152
assertneq(10, 20, "10 should not equal 20");
153153
var _ = print_line("All assertions passed!");
154154

155+
var _ = print_line("=== 15. File I/O ===");
156+
val test_file = "examples/rpython_test.txt";
157+
var _ = open(test_file, "w", "Hello from RPython!");
158+
var _ = print("Wrote to file. Reading back: ");
159+
val contents = open(test_file, "r");
160+
var _ = print_line(contents);
161+
var _ = open(test_file, "a", "Appended line.");
162+
val contents2 = open(test_file, "r");
163+
var _ = print("After append: ");
164+
var _ = print_line(contents2);
165+
155166
var _ = print_line("=== Demo Complete ===");

examples/rpython_test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello from RPython!Appended line.

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ fn main() {
5757
std::process::exit(1);
5858
}
5959
}
60-
}
60+
}

0 commit comments

Comments
 (0)