@@ -37,7 +37,7 @@ use string::{ split, join };
3737///
3838/// Example:
3939/// printf("Hello, {}! You are {} years old.", ["Alice", 30])
40- fn printf(format: String, args: [Any]) -> () {
40+ pub fn printf(format: String, args: [Any]) -> () {
4141 let flen = len(format);
4242 let mut arg_idx = 0;
4343 let mut i = 0;
@@ -59,23 +59,23 @@ fn printf(format: String, args: [Any]) -> () {
5959}
6060
6161/// Print formatted string with trailing newline
62- fn println_fmt(format: String, args: [Any]) -> () {
62+ pub fn println_fmt(format: String, args: [Any]) -> () {
6363 printf(format, args);
6464 println("");
6565}
6666
6767/// Print debug representation of any value
68- fn debug<T>(value: T) -> () {
68+ pub fn debug<T>(value: T) -> () {
6969 eprintln("DEBUG: " ++ show(value));
7070}
7171
7272/// Print error with newline to stderr (convenience wrapper)
73- fn error(msg: String) -> () {
73+ pub fn error(msg: String) -> () {
7474 eprintln("[ERROR] " ++ msg);
7575}
7676
7777/// Print warning with newline to stderr
78- fn warn(msg: String) -> () {
78+ pub fn warn(msg: String) -> () {
7979 eprintln("[WARN] " ++ msg);
8080}
8181
@@ -86,7 +86,7 @@ fn warn(msg: String) -> () {
8686// read_file, write_file, append_file, file_exists are builtins — see module header
8787
8888/// Read file as a list of lines
89- fn read_lines(path: String) -> Result<[String], String> {
89+ pub fn read_lines(path: String) -> Result<[String], String> {
9090 match read_file(path) {
9191 Ok(content) => Ok(split(content, "\n")),
9292 Err(msg) => Err(msg)
@@ -97,7 +97,7 @@ fn read_lines(path: String) -> Result<[String], String> {
9797///
9898/// Note: this reads the entire file; a more efficient builtin would be
9999/// preferable for large files once the runtime supports stat().
100- fn file_size(path: String) -> Result<Int, String> {
100+ pub fn file_size(path: String) -> Result<Int, String> {
101101 match read_file(path) {
102102 Ok(content) => Ok(len(content)),
103103 Err(msg) => Err(msg)
@@ -124,7 +124,7 @@ extern fn remove_dir(path: String) -> Result<(), String>;
124124// ============================================================================
125125
126126/// Join path components with the system separator (/)
127- fn path_join(components: [String]) -> String {
127+ pub fn path_join(components: [String]) -> String {
128128 let mut result = "";
129129 let mut first = true;
130130 for component in components {
@@ -142,7 +142,7 @@ fn path_join(components: [String]) -> String {
142142///
143143/// Returns None if no extension is found.
144144/// Example: path_extension("file.txt") => Some("txt")
145- fn path_extension(path: String) -> Option<String> {
145+ pub fn path_extension(path: String) -> Option<String> {
146146 let plen = len(path);
147147 let mut i = plen - 1;
148148 while i >= 0 {
@@ -166,7 +166,7 @@ fn path_extension(path: String) -> Option<String> {
166166/// Get the filename component from a path
167167///
168168/// Example: path_filename("/home/user/file.txt") => "file.txt"
169- fn path_filename(path: String) -> String {
169+ pub fn path_filename(path: String) -> String {
170170 let plen = len(path);
171171 if plen == 0 {
172172 return "";
@@ -185,7 +185,7 @@ fn path_filename(path: String) -> String {
185185/// Get the directory component from a path
186186///
187187/// Example: path_dirname("/home/user/file.txt") => "/home/user"
188- fn path_dirname(path: String) -> String {
188+ pub fn path_dirname(path: String) -> String {
189189 let plen = len(path);
190190 if plen == 0 {
191191 return ".";
@@ -207,7 +207,7 @@ fn path_dirname(path: String) -> String {
207207/// Get the filename without its extension (stem)
208208///
209209/// Example: path_stem("archive.tar.gz") => "archive.tar"
210- fn path_stem(path: String) -> String {
210+ pub fn path_stem(path: String) -> String {
211211 let filename = path_filename(path);
212212 let flen = len(filename);
213213 let mut i = flen - 1;
@@ -239,7 +239,7 @@ extern fn chdir(path: String) -> Result<(), String>;
239239// read_line is a builtin — see module header
240240
241241/// Read all input from stdin until EOF
242- fn read_stdin() -> Result<String, String> {
242+ pub fn read_stdin() -> Result<String, String> {
243243 let mut parts = [];
244244 let mut done = false;
245245 while !done {
@@ -256,7 +256,7 @@ fn read_stdin() -> Result<String, String> {
256256}
257257
258258/// Prompt user for input and return their response
259- fn prompt(message: String) -> Result<String, String> {
259+ pub fn prompt(message: String) -> Result<String, String> {
260260 print(message);
261261 read_line()
262262}
@@ -268,7 +268,7 @@ fn prompt(message: String) -> Result<String, String> {
268268// time_now is a builtin — see module header
269269
270270/// Measure the wall-clock time of a function call (in seconds)
271- fn timed<T>(f: () -> T) -> (T, Float) {
271+ pub fn timed<T>(f: () -> T) -> (T, Float) {
272272 let start = time_now();
273273 let result = f();
274274 let elapsed = time_now() - start;
0 commit comments