Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(string): handle temp_ascii_to_lower arguments properly #1505

Closed
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
22 changes: 18 additions & 4 deletions lib/std/core/string.c3
Original file line number Diff line number Diff line change
Expand Up @@ -533,16 +533,29 @@ fn void String.convert_ascii_to_lower(s)
foreach (&c : s) if (c.is_upper() @pure) *c += 'a' - 'A';
}

/**
* Returns a string converted to ASCII lower case.
*
* @param [in] s
* @param [inout] allocator
*
* @return `a new String converted to ASCII lower case.`
**/
fn String String.new_ascii_to_lower(s, Allocator allocator = allocator::heap())
{
String copy = s.copy(allocator);
copy.convert_ascii_to_lower();
return copy;
}

fn String String.temp_ascii_to_lower(s, Allocator allocator = allocator::heap())
/**
* @param [in] s
* @param [inout] allocator
* @return `a temporary String converted to ASCII lower case.`
**/
fn String String.temp_ascii_to_lower(s, Allocator allocator = allocator::temp())
{
return s.new_ascii_to_lower(allocator::temp());
return s.new_ascii_to_lower(allocator);
}

/**
Expand Down Expand Up @@ -578,11 +591,12 @@ fn StringIterator String.iterator(s)

/**
* @param [in] s
* @param [inout] allocator
* @return `a temporary String converted to ASCII upper case.`
**/
fn String String.temp_ascii_to_upper(s)
fn String String.temp_ascii_to_upper(s, Allocator allocator = allocator::temp())
{
return s.new_ascii_to_upper(allocator::temp());
return s.new_ascii_to_upper(allocator);
}

fn String! new_from_utf32(Char32[] utf32, Allocator allocator = allocator::heap())
Expand Down
Loading