This should work:

let obj = (self.produce_obj)();


-------- Original Message --------
From: Oren Ben-Kiki <[email protected]>
Sent: Fri Nov 08 18:33:23 EST 2013
To: wuyunlong <[email protected]>
Cc: "[email protected]" <[email protected]>
Subject: Re: [rust-dev] Help: How to execute the owned method "produce_obj"?

It wouldn't be self.something because it doesn't take a self argument.
Try Pool::produce_obj::<T>(...) ?
Or add a self argument to it and then call it normally.


On Sat, Nov 9, 2013 at 1:31 AM, wuyunlong <[email protected]> wrote:

> struct Pool<T>{
>         produce_obj : ~fn()->T,
>         elements : ~[T]
> }
>
> impl<T:Send> Pool<T>{
>
>          fn new_obj(&mut self){
>               let obj = self. ... ;*// Here ,how to execute method
> "produce_obj" ?*
>               self.elements.push(obj);
>          }
> }
>
>
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev
>
>


------------------------------------------------------------------------

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to