Re: [rust-dev] Error: cannot borrow `***test` as mutable because it is also borrowed as immutable in match

2014-04-28 Thread Philippe Delrieu
Hello, I've updated my sample code to reflect what I'll do in my main program. I put it back on the list because it can help as a pattern to manage a tree of polymorph object. It compile and works. I have some question too because I'm not sure I've done it the right way: * I cross the tree

Re: [rust-dev] Error: cannot borrow `***test` as mutable because it is also borrowed as immutable in match

2014-04-27 Thread Philippe Delrieu
I try to implement a sort of zoom UI. The UI components are organized in a tree. To update a component in the UI I use a search function (match_fn() in the example) which take a closure as search criteria and if it returns something I use an update function (test_mutable) with a closure to do

Re: [rust-dev] Error: cannot borrow `***test` as mutable because it is also borrowed as immutable in match

2014-04-25 Thread Philippe Delrieu
), None = {}, } } } #[main] fn main() { TestMatchBorrow(); } ** On Thu, Apr 24, 2014 at 9:23 PM, Philippe Delrieu philippe.delr...@free.fr mailto:philippe.delr...@free.fr wrote: Hello, I have a problem in my

[rust-dev] Error: cannot borrow `***test` as mutable because it is also borrowed as immutable in match

2014-04-24 Thread Philippe Delrieu
Hello, I have a problem in my code and I can't find a solution. I develop a test case that generate the same error. Any idea? use std::vec::Vec; use std::rc::Rc; use std::cell::RefCell; struct Test; impl Test { fn match_fn'a('a self) -Option'a Test { None } fn

Re: [rust-dev] Some help needed in Vector of enum conversion

2014-04-10 Thread Philippe Delrieu
to an object. So it seems that tray is useful to pass or return parameters to method but not to store data. Philippe Le 09/04/2014 21:53, Philippe Delrieu a écrit : I find a solution by removing the ~ to Base trait. The code //(First and Second think as defined earlier) enum BaseImpl

[rust-dev] does not fulfill `Send` error since last pull request

2014-04-10 Thread Philippe Delrieu
Since my last today gill fetch I have this error: error: instantiating a type parameter with an incompatible type `~BaseImpl`, which does not fulfill `Send` for this code : trait Base{} struct SecondThink{ count2: int, } enum BaseImpl{ FirstThinkImpl(~Base),

Re: [rust-dev] Some help needed in Vector of enum conversion

2014-04-09 Thread Philippe Delrieu
(){ println!(ici Second count:{:?}, think.isSecondThink()); } for think in container.iter_second(){ println!(ici Second count:{:?}, think.isSecondThink()); } container.appli_secondthink_someprocess(some_second_process); } Le 07/04/2014 13:17, Philippe Delrieu a écrit

Re: [rust-dev] Some help needed in Vector of enum conversion

2014-04-07 Thread Philippe Delrieu
Thanks for your help. I'll test ASAP. I use the counter mutable var to have a simple implantation of the iterator to make the code works. Thank for you're example to show a better way. I was thinking of a similar way but I would like to avoid the specific struct with perhaps use a recursive

Re: [rust-dev] Some help needed in Vector of enum conversion

2014-04-07 Thread Philippe Delrieu
, Rodrigo Rivas a écrit : On Sun, Apr 6, 2014 at 7:50 PM, Philippe Delrieu philippe.delr...@free.fr wrote: I need some more help. The impl Iteratormut ~Base for Container declaration generate the error: error: missing lifetime specifier So I had it but I can't manage to return the next value

Re: [rust-dev] Some help needed in Vector of enum conversion

2014-04-06 Thread Philippe Delrieu
, Le 05/04/2014 21:59, Rodrigo Rivas a écrit : On Fri, Apr 4, 2014 at 10:41 PM, Philippe Delrieu philippe.delr...@free.fr wrote: Hello, I've some problem to find a solution for something I want to do with a vector of enum. This is an example of what I want to do: trait Base{ fn

Re: [rust-dev] Some help needed in Vector of enum conversion

2014-04-05 Thread Philippe Delrieu
Very good idea. The vector don't have to be modified so it'll work. Thank you for the advice. I make a try an I'll post the result. Philippe Le 05/04/2014 21:59, Rodrigo Rivas a écrit : On Fri, Apr 4, 2014 at 10:41 PM, Philippe Delrieu philippe.delr...@free.fr wrote: Hello, I've some

[rust-dev] Some help needed in Vector of enum conversion

2014-04-04 Thread Philippe Delrieu
Hello, I've some problem to find a solution for something I want to do with a vector of enum. This is an example of what I want to do: trait Base{ fn set_something(mut self); } struct FirstThink; impl Base for FirstThink{ fn set_something(mut self){} } struct SecondThink;

Re: [rust-dev] Using a closure as a return value

2014-02-22 Thread Philippe Delrieu
Thank for you reply. But I don't see any solution to my problem.. I'll explain it a little more. I want to develop a sort of GUI. The GUI has its own logic and use a rendering engine to do the work. I want my GUI separate of the rendering engine. In the first solution I use a trait that hide

Re: [rust-dev] How to use dynamic polymorphism with collection

2014-02-09 Thread Philippe Delrieu
don't find the answer I'll post a new example. Philippe Le 09/02/2014 00:56, Ashish Myles a écrit : On Sat, Feb 8, 2014 at 6:48 PM, Ashish Myles marci...@gmail.com mailto:marci...@gmail.com wrote: On Sat, Feb 8, 2014 at 1:21 PM, Philippe Delrieu philippe.delr...@free.fr

Re: [rust-dev] rustpkg error: Package ____ depends on ____, but I don't know how to find it

2014-01-28 Thread Philippe Delrieu
Any info or idea? I update from the master and now all my project have the same issue. If I use rustc I have no problem. I see the thread about rustpkg, perhaps I should migrate to rustc and cmake? Philippe Le 26/01/2014 16:25, Philippe Delrieu a écrit : Hi, I have the same problem since 2

Re: [rust-dev] Bitwise operations in rust.

2014-01-15 Thread Philippe Delrieu
Thanks for you answer . I have the idea to see in the SDL port (I work on the SDL2 port) which is finished and has the same problems. They solve the problem like this : pub fn unfold_bits(bitflags: u32) - ~[SDL_WindowFlags] { let flags = [SDL_WINDOW_FULLSCREEN,

Re: [rust-dev] error: can't find crate for `std`

2014-01-03 Thread Philippe Delrieu
I found the problem. I had to rebuild all my external C binding that was compiled with the old version of rustc. Before rustc were crashing. Now I have this error. Philippe Le 02/01/2014 22:40, Philippe Delrieu a écrit : I update with the master and now I have this error with a code

[rust-dev] error: can't find crate for `std`

2014-01-02 Thread Philippe Delrieu
I update with the master and now I have this error with a code that was compiling before. ... rs:1:1: 1:1 error: can't find crate for `std` The error is at the first line which ever was the first line. Not all crate have the problem. Philippe Delrieu

Re: [rust-dev] How to send a closure in a task

2013-12-25 Thread Philippe Delrieu
`, in a bounded closure The function signature : pub fn Pt_startT:Send (self, resolution : u64, userData : T , callback: 'static |u64, T|) { Philippe Le 24/12/2013 19:06, Patrick Walton a écrit : On 12/24/13 3:41 AM, Philippe Delrieu wrote: Hello, I try to capture a closure in a task and I have

[rust-dev] How to send a closure in a task

2013-12-24 Thread Philippe Delrieu
(); callback(10, userData); } } } thank for your help. Philippe Delrieu ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev

[rust-dev] new compile errors in the master since a few days

2013-12-05 Thread Philippe Delrieu
); ^~~~ I have the same type of errors in my code plus other error when the trait can't be found like type `MyType` does not implement any method in scope named `encode` and the function is implemented just above. This code where compiling last week. Philippe Delrieu

Re: [rust-dev] new compile errors in the master since a few days

2013-12-05 Thread Philippe Delrieu
something like let rc = endpoint.with_c_str(|cstr| { unsafe {smq_bind(self.sock, cstr)} }); I can't speculate on your encode error without seeing it. -Kevin On Dec 5, 2013, at 12:43 AM, Philippe Delrieu philippe.delr...@free.fr wrote: Hello, since a few days, I have a lot of new

Re: [rust-dev] new compile errors in the master since a few days

2013-12-05 Thread Philippe Delrieu
` not found for encode, or to add all `use` needed when using a type and its implementation. Philippe Le 05/12/2013 10:53, Philippe Delrieu a écrit : Thank you it correct my first problems. I didn't send code because I thought it has the same cause. For the last problems the code is : use extra

Re: [rust-dev] new compile errors in the master since a few days

2013-12-05 Thread Philippe Delrieu
with that signature, but even that wouldn't be great if you had the signature off. On Thu, Dec 5, 2013 at 3:26 PM, Philippe Delrieu philippe.delr...@free.fr wrote: I found my error. It's a classical problem. TestStruct2 implement the trait `extra::serialize::Encodable` using the generated impl by the compiler. I

Re: [rust-dev] new compile errors in the master since a few days

2013-12-05 Thread Philippe Delrieu
I find this message better than the current. It won't mislead me. Le 05/12/2013 22:50, Corey Richardson a écrit : How about method `foo` no found and no trait in scope provided one ? On Thu, Dec 5, 2013 at 4:29 PM, Philippe Delrieu philippe.delr...@free.fr wrote: Perhaps the error message can

Re: [rust-dev] Problem to use Encodable as fn parameter

2013-12-04 Thread Philippe Delrieu
Delrieu Le 01/12/2013 18:28, Philippe Delrieu a écrit : I see the PR has been approved to I try to implements the method 'pub fn buffer_encodeT:EncodableEncoder(to_encode_object: T) - ~[u8]' and I have this error : error: wrong number of lifetime parameters: expected 1 but found 0 and indicate

Re: [rust-dev] Problem to use Encodable as fn parameter

2013-11-29 Thread Philippe Delrieu
str_encodeT:EncodableEncoder(to_encode_object: T) - ~str pub fn buffer_encodeT:EncodableEncoder(to_encode_object: T) - ~[u8] and remove the other. Any remaqs? Philippe Le 29/11/2013 10:44, Gaetan a écrit : I would prefere this function returns a str. Le 29 nov. 2013 09:27, Philippe Delrieu philippe.delr

Re: [rust-dev] Problem to use Encodable as fn parameter

2013-11-29 Thread Philippe Delrieu
); to_encode_object.encode(mut encoder); let buff:~[u8] = m.inner_ref(); str::from_utf8(*buff) } I'll do at least one copy (one less than the other impl) but the code is copied. Is there a better way to manage pointer of memory across function calls? Philippe Le 29/11/2013 12:55, Philippe Delrieu

[rust-dev] Problem to use Encodable as fn parameter

2013-11-28 Thread Philippe Delrieu
MemWriter But I can't use the method with a struct that implement Encodable. The error : mismatched types: expected `V31` but found .. I have another question : I would like to return a MemWriter and not a @mut MemWriter . I didn't find a way to convert the @mut to ~ Philippe Delrieu

Re: [rust-dev] Json example code

2013-11-26 Thread Philippe Delrieu
change. Philippe Delrieu Le 22/11/2013 19:22, Philippe Delrieu a écrit : I've done the modification in json.rs (add comment with sample code in md format and test code). I've do the commit and git pull. The test compile but I didn't manage to run it. I use the command: make -j 20 check

Re: [rust-dev] error: cannot move out of dereference of @ pointer

2013-11-22 Thread Philippe Delrieu
'undecorate' a Reader/Writer /// that has been boxed. Is that ok? This feature is mostly useful for /// extracting the buffer from MemWriter fn inner(self) - T; My second question is how to convert a ~[u8] to a ~std ? Philippe Delrieu

[rust-dev] Json example code

2013-11-22 Thread Philippe Delrieu
= Philippe Delrieu)]; #[feature(managed_boxes)]; extern mod extra; use std::io::mem::MemWriter; use extra::serialize::Decodable; use extra::serialize::Encodable; use extra::serialize::Encoder; use extra::json::{Json, Decoder, ToJson, Object}; use extra::treemap::TreeMap; use std::io::Decorator

[rust-dev] error: cannot move out of dereference of @ pointer

2013-11-20 Thread philippe . delrieu
a ~[u8] to a ~std ? Philippe Delrieu ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev

Re: [rust-dev] How to cast a @type in a @trait

2013-11-20 Thread philippe . delrieu
Selon Philippe Delrieu philippe.delr...@free.fr: Thanks you it works in my simple test but I have this error when I add it in my program : error: can't find crate for `std` I try to find why it doesn't work in my program and I found the error occurs when I add the extern mod zmq;. Perhaps I

Re: [rust-dev] Rust docs

2013-11-19 Thread Philippe Delrieu
Hello, I would like to share my experience about the Rust doc and the tutorial. I've just started to learn Rust and I've decided to use it on a project I work on. Like everybody I read the Rust tutorial. It's not a really a tutorial for beginner but it do a good job in presenting Rust and its

Re: [rust-dev] Rust docs

2013-11-19 Thread Philippe Delrieu
is in the module documentation. - Gaetan 2013/11/19 Philippe Delrieu philippe.delr...@free.fr mailto:philippe.delr...@free.fr Hello, I would like to share my experience about the Rust doc and the tutorial. I've just started to learn Rust and I've decided

[rust-dev] How to cast a @type in a @trait

2013-11-19 Thread Philippe Delrieu
I still struggle with the json API. I try it using encode and decode API and I face a problem. I take this code in the json test case : let m = @mut MemWriter::new(); f(m as @mut io::Writer); and I have an error : The managed box syntax will be replaced by a library type, and a

[rust-dev] zmq and Rust task

2013-11-08 Thread Philippe Delrieu
!(Received {}, s); } responder.send_str(World, 0); timer::sleep(100); } } timer::sleep(1); } Philippe Delrieu ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust

Re: [rust-dev] Access error for trait implemtation in multiple file

2013-11-08 Thread Philippe Delrieu
. It make me think about I#ifndef in C. Philippe Delrieu Le 08/11/2013 09:53, Alex Crichton a écrit : You should be careful to declare modules only once. It looks like you have two instances of mod actions in the module hierarchy, and both modules will be compiled as separate entities

Re: [rust-dev] zmq and Rust task

2013-11-08 Thread Philippe Delrieu
::SingleThreaded) and now it work. Philippe Delrieu ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev

Re: [rust-dev] zmq and Rust task

2013-11-08 Thread Philippe Delrieu
of a socket to libuv to protect against task deadlocking. On Friday, November 8, 2013, Philippe Delrieu wrote: I found the problem. Rust schedules task in the same thread. If I stop the thread (the recv call sleep I think), every task stop. So I read the doc and I see the spawn_sched method

Re: [rust-dev] Access error for trait implemtation in multiple file

2013-11-08 Thread Philippe Delrieu
I solve my problem by using absolute path every where. It's ok but I can't use the source file in another program with another root module. Philippe Delrieu I've read the tutorial Le 08/11/2013 20:36, Alex Crichton a écrit : I would recommend reading about Rust's module system at http

[rust-dev] Access error for trait implemtation in multiple file

2013-11-07 Thread Philippe Delrieu
::actions::Action; //error here println(process element : + actelm.process()); = generate error: trait `Action` is inaccessible If I put testaction content in the test file rustc compile. Any idea? Philippe Delrieu ___ Rust-dev mailing