Skip to content

Commit 15be2fc

Browse files
committed
Add 'copy' bounds to functions that were faultily accepted without
Issue #1390
1 parent 8c14943 commit 15be2fc

9 files changed

+12
-12
lines changed

src/libcore/option.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pure fn get<copy T>(opt: t<T>) -> T {
3636

3737
/*
3838
*/
39-
fn map<T, U>(opt: t<T>, f: block(T) -> U) -> t<U> {
39+
fn map<T, copy U>(opt: t<T>, f: block(T) -> U) -> t<U> {
4040
alt opt { some(x) { some(f(x)) } none. { none } }
4141
}
4242

@@ -61,7 +61,7 @@ Function: from_maybe
6161
6262
Returns the contained value or a default
6363
*/
64-
pure fn from_maybe<T>(def: T, opt: t<T>) -> T {
64+
pure fn from_maybe<copy T>(def: T, opt: t<T>) -> T {
6565
alt opt { some(x) { x } none. { def } }
6666
}
6767

@@ -70,7 +70,7 @@ Function: maybe
7070
7171
Applies a function to the contained value or returns a default
7272
*/
73-
fn maybe<T, U>(def: U, opt: t<T>, f: block(T) -> U) -> U {
73+
fn maybe<T, copy U>(def: U, opt: t<T>, f: block(T) -> U) -> U {
7474
alt opt { none. { def } some(t) { f(t) } }
7575
}
7676

src/libcore/result.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Failure:
3737
3838
If the result is an error
3939
*/
40-
fn get<T, U>(res: t<T, U>) -> T {
40+
fn get<copy T, U>(res: t<T, U>) -> T {
4141
alt res {
4242
ok(t) { t }
4343
err(_) {
@@ -57,7 +57,7 @@ Failure:
5757
5858
If the result is not an error
5959
*/
60-
fn get_err<T, U>(res: t<T, U>) -> U {
60+
fn get_err<T, copy U>(res: t<T, U>) -> U {
6161
alt res {
6262
err(u) { u }
6363
ok(_) {

src/libstd/deque.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn create<copy T>() -> t<T> {
5757

5858
ret rv;
5959
}
60-
fn get<T>(elts: [mutable cell<T>], i: uint) -> T {
60+
fn get<copy T>(elts: [mutable cell<T>], i: uint) -> T {
6161
ret alt elts[i] { option::some(t) { t } _ { fail } };
6262
}
6363
obj deque<copy T>(mutable nelts: uint,

src/libstd/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Function: id
77
88
The identity function
99
*/
10-
pure fn id<T>(x: T) -> T { x }
10+
pure fn id<copy T>(x: T) -> T { x }
1111

1212
/*
1313
Function: unreachable

src/test/run-pass/expr-alt-generic-box2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// -*- rust -*-
55
type compare<T> = fn@(T, T) -> bool;
66

7-
fn test_generic<T>(expected: T, eq: compare<T>) {
7+
fn test_generic<copy T>(expected: T, eq: compare<T>) {
88
let actual: T = alt true { true { expected } };
99
assert (eq(expected, actual));
1010
}

src/test/run-pass/expr-alt-generic-unique1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// -*- rust -*-
44
type compare<T> = fn@(~T, ~T) -> bool;
55

6-
fn test_generic<T>(expected: ~T, eq: compare<T>) {
6+
fn test_generic<copy T>(expected: ~T, eq: compare<T>) {
77
let actual: ~T = alt true { true { expected } };
88
assert (eq(expected, actual));
99
}

src/test/run-pass/expr-alt-generic-unique2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// -*- rust -*-
55
type compare<T> = fn@(T, T) -> bool;
66

7-
fn test_generic<T>(expected: T, eq: compare<T>) {
7+
fn test_generic<copy T>(expected: T, eq: compare<T>) {
88
let actual: T = alt true { true { expected } };
99
assert (eq(expected, actual));
1010
}

src/test/run-pass/expr-alt-generic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// -*- rust -*-
55
type compare<T> = fn@(T, T) -> bool;
66

7-
fn test_generic<T>(expected: T, eq: compare<T>) {
7+
fn test_generic<copy T>(expected: T, eq: compare<T>) {
88
let actual: T = alt true { true { expected } };
99
assert (eq(expected, actual));
1010
}

src/test/run-pass/expr-fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn test_vec() {
99
}
1010

1111
fn test_generic() {
12-
fn f<T>(t: T) -> T { t }
12+
fn f<copy T>(t: T) -> T { t }
1313
assert (f(10) == 10);
1414
}
1515

0 commit comments

Comments
 (0)