2 #![allow(non_camel_case_types)]
7 fn to_string_(&self) -> String
;
9 impl to_str
for isize {
10 fn to_string_(&self) -> String { self.to_string() }
12 impl to_str
for String
{
13 fn to_string_(&self) -> String { self.clone() }
16 fn to_string_(&self) -> String { "()".to_string() }
20 fn map
<U
, F
>(&self, f
: F
) -> Vec
<U
> where F
: FnMut(&T
) -> U
;
22 impl<T
> map
<T
> for Vec
<T
> {
23 fn map
<U
, F
>(&self, mut f
: F
) -> Vec
<U
> where F
: FnMut(&T
) -> U
{
24 let mut r
= Vec
::new();
32 fn foo
<U
, T
: map
<U
>>(x
: T
) -> Vec
<String
> {
33 x
.map(|_e
| "hi".to_string() )
35 fn bar
<U
:to_str
,T
:map
<U
>>(x
: T
) -> Vec
<String
> {
36 x
.map(|_e
| _e
.to_string_() )
40 assert_eq
!(foo(vec
![1]), ["hi".to_string()]);
41 assert_eq
!(bar
::<isize, Vec
<isize> >(vec
![4, 5]), ["4".to_string(), "5".to_string()]);
42 assert_eq
!(bar
::<String
, Vec
<String
> >(vec
!["x".to_string(), "y".to_string()]),
43 ["x".to_string(), "y".to_string()]);
44 assert_eq
!(bar
::<(), Vec
<()>>(vec
![()]), ["()".to_string()]);