aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/borrows_clause.zc
blob: 6f4358177ecb65a57a9f2fbc2055e45d49ed3ed2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
namespace;
include rt;
// a borrows clause on a prototype and its definition: freeing the other argument keeps the result.
char* first(char* a, char* b) borrows a;
fn main() {
	char* t = rt.new(4); t[0] = 'x'; t[1] = 0;
	char* u = rt.new(4); u[0] = 'y'; u[1] = 0;
	let r = first(t, u); rt.free(u); rt.put_c(r[0]); rt.free(t);
	return 0;
}
char* first(char* a, char* b) borrows a { return a; }