Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions stdlib/io.affine
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ use string::{ split, join };
/// printf("Hello, {}! You are {} years old.", ["Alice", 30])
fn printf(format: String, args: [Any]) -> () {
let flen = len(format);
let arg_idx = 0;
let i = 0;
let mut arg_idx = 0;
let mut i = 0;

while i < flen {
if i + 1 < flen && string_sub(format, i, 2) == "{}" {
Expand Down Expand Up @@ -124,7 +124,7 @@ extern fn remove_dir(path: String) -> Result<(), String>;

/// Join path components with the system separator (/)
fn path_join(components: [String]) -> String {
let result = "";
let mut result = "";
let mut first = true;
for component in components {
if first {
Expand All @@ -143,7 +143,7 @@ fn path_join(components: [String]) -> String {
/// Example: path_extension("file.txt") => Some("txt")
fn path_extension(path: String) -> Option<String> {
let plen = len(path);
let i = plen - 1;
let mut i = plen - 1;
while i >= 0 {
let ch = string_get(path, i);
if ch == '.' {
Expand All @@ -170,7 +170,7 @@ fn path_filename(path: String) -> String {
if plen == 0 {
return "";
}
let i = plen - 1;
let mut i = plen - 1;
while i >= 0 {
if string_get(path, i) == '/' {
return string_sub(path, i + 1, plen - i - 1);
Expand All @@ -189,7 +189,7 @@ fn path_dirname(path: String) -> String {
if plen == 0 {
return ".";
}
let i = plen - 1;
let mut i = plen - 1;
while i >= 0 {
if string_get(path, i) == '/' {
if i == 0 {
Expand All @@ -209,7 +209,7 @@ fn path_dirname(path: String) -> String {
fn path_stem(path: String) -> String {
let filename = path_filename(path);
let flen = len(filename);
let i = flen - 1;
let mut i = flen - 1;
while i > 0 {
if string_get(filename, i) == '.' {
return string_sub(filename, 0, i);
Expand Down Expand Up @@ -239,8 +239,8 @@ extern fn chdir(path: String) -> Result<(), String>;

/// Read all input from stdin until EOF
fn read_stdin() -> Result<String, String> {
let parts = [];
let done = false;
let mut parts = [];
let mut done = false;
while !done {
match read_line() {
Ok(line) => {
Expand Down
Loading