[rust-dev] reference has a longer lifetime than the data it references

2014-09-11 Thread Christophe Pedretti
Hello, with 0.11.0, this code was ok pub struct Cursor'a, 'b { pStmt : 'b Statement'a, error : bool } now, with the nighly, i receive a sql\connection.rs:50:1: 53:2 error: in type `'b sql::connection::Statement'a`, reference has a longer lifetime than the data it references

Re: [rust-dev] Generic Database Bindings

2014-06-09 Thread Christophe Pedretti
i have started a small personal project, with for the moment, an only (but working) SQLite suport, you can find it here mainpage : http://chris-pe.github.io/Rustic/ github : https://github.com/chris-pe/Rustic documentation : http://www.rust-ci.org/chris-pe/Rustic/doc/rustic/ An example of how to

Re: [rust-dev] Generic Database Bindings

2014-06-09 Thread Christophe Pedretti
on it . * Laxmi Narayan Patel* * MCA NIT Durgapur ( Final year)* * Mob:-8345847473* On Mon, Jun 9, 2014 at 2:27 PM, Christophe Pedretti christophe.pedre...@gmail.com wrote: i have started a small personal project, with for the moment

Re: [rust-dev] Passing arguments bu reference

2014-06-02 Thread Christophe Pedretti
Great Thanks to all, now i have a more precise idea. So, to summarize if the function takes a vector as argument, transforms it, and return it, with no need for the caller to use the argument fn my_func(src: Vecu8) - Vecu8 if the functons takes a vector argument and use it just for a temporary

[rust-dev] Passing arguments bu reference

2014-06-01 Thread Christophe Pedretti
Hello all, I've read this : http://words.steveklabnik.com/pointers-in-rust-a-guide I am coming from Java where everything is passed and returned by reference (except for primitive data types), no choice. I know that with C, you have to use pointers to avoid passing and returning by value. When

[rust-dev] Using String and StrSlice

2014-06-01 Thread Christophe Pedretti
Hi all, suppose i want to replace the i th character c (this character is ascii, so represented by exactly one byte) in a String named buf with character 'a' i can do this buf = buf.as_slice().slice_to(i).to_string().append(a).append(buf.as_slice().slice_from(i+1)) if c is any UTF8 character, i

Re: [rust-dev] Calling a method while iterating over a field of the object

2014-06-01 Thread Christophe Pedretti
and using mut_iter() instead of iter() is not enough ? 2014-06-01 22:03 GMT+02:00 Cameron Zwarich zwar...@mozilla.com: The simplest thing to do is probably to build an intermediate vector of vertices to insert and then push them all after you are done iterating over the edges. Cameron

Re: [rust-dev] cannot borrow `st` as mutable more than once at a time

2014-05-31 Thread Christophe Pedretti
using a new lifetime. pub fn execute_query'b('b mut self) - ResultSelf'b; -Kevin On May 30, 2014, at 1:54 AM, Christophe Pedretti christophe.pedre...@gmail.com wrote: Hi All, sorry for my late replay, i am UTC+2 Won't wrapping the first `for` loop into curly braces help

[rust-dev] failed to find an implementation of trait core::cmp::TotalEq for ~str

2014-05-31 Thread Christophe Pedretti
Hi all, i have updated my rust compiler, i have several compilations errors on my project 1. StrBuf does not exist any more, no problem, i now use String 2. ~ is obsolete, no problem, i use box 3. The last isssue is failed to find an implementation of trait core::cmp::TotalEq for

Re: [rust-dev] failed to find an implementation of trait core::cmp::TotalEq for ~str

2014-05-31 Thread Christophe Pedretti
{ self.props.contains_key(key) } } 2014-05-31 22:21 GMT+04:00 Christophe Pedretti christophe.pedre...@gmail.com: Hi all, i have updated my rust compiler, i have several compilations errors on my project StrBuf does not exist any more, no problem, i now use String ~ is obsolete, no problem, i

Re: [rust-dev] cannot borrow `st` as mutable more than once at a time

2014-05-30 Thread Christophe Pedretti
Hi All, sorry for my late replay, i am UTC+2 Won't wrapping the first `for` loop into curly braces help? no is this a database library you're writing yourself? yes My best guess here is that you've accidentally used the wrong lifetime on your `execute_query()` method, tying the lifetime of

[rust-dev] cannot borrow `st` as mutable more than once at a time

2014-05-29 Thread Christophe Pedretti
Hello all, i know that this issue is already covered by issues #9113 #6393 and #9113 but actually i have no solution. My code is a library for accessing databases. In my example, the database represented by db containes a table t with columns i:integer, f:float, t:text, b:blob. Everything works

[rust-dev] How to implement a singleton ?

2014-05-15 Thread Christophe Pedretti
I am trying to implement a Singleton (an object which instantiate only once, successive instantiations returning the object itself). Any tutorial for this ? any idea ? example ? best practice ? thanks ___ Rust-dev mailing list Rust-dev@mozilla.org

Re: [rust-dev] Casting *c_uchar to *c_char

2014-05-13 Thread Christophe Pedretti
= if tmp.is_not_null {let tmp_str = tmp .as_str()}; tmp_str.clone() } Thanks 2014-05-13 1:24 GMT+02:00 comex com...@gmail.com: On Mon, May 12, 2014 at 6:41 PM, Christophe Pedretti christophe.pedre...@gmail.com wrote: Another SQLite function, sqlite3_column_text, return a *c_uchar; so, tu use the CString new

[rust-dev] How to translate and use a void(*)(void*) in Rust ?

2014-05-13 Thread Christophe Pedretti
Hi all, SQLITE is defining the following C function : int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*)); How to include it in an extern block ? I have tried this fn sqlite3_bind_text(pStmt : *mut(), iCol : c_int, value : *c_char, n : c_int, f : *proc(*())) - c_int;

[rust-dev] Casting *c_uchar to *c_char

2014-05-12 Thread Christophe Pedretti
Hi all, Vladimir suggested to use CString::new(sqlite3_errmsg(*ppDb), false) and then as_str() on the CString in order to obtain a Rust String from a *c_char. Another SQLite function, sqlite3_column_text, return a *c_uchar; so, tu use the CString new, which takes a *c_char as argument, i can

[rust-dev] *c_char and *c_uchar

2014-05-10 Thread Christophe Pedretti
Hi all, i am writing a wrapper to an SQLite database. If i use : extern { fn sqlite3_open(filename: *c_char, ppDb : **mut ()) - c_int; } i can not use : let ppDb : **mut () = RawPtr::null(); unsafe { res=sqlite3_open(filename.as_ptr(), ppDb); because as_ptr() returns an *u8 and c_char is a i8,

[rust-dev] 3 ways to do, which is the best one in terms of Rust philosophy ?

2014-05-10 Thread Christophe Pedretti
Hi all, thanks to Vladimir and Valerii for their previous detailed answer to my email, now i have a more general question. My Connection struct has a new method with open a connection to a database. This connection can fails. Three possiblities : 1/ new returns an IoResultConnection. The

[rust-dev] How to convert ~str to str

2014-05-06 Thread Christophe Pedretti
Hi all, i would like to parse a file, line by line, and when a line finishes with '\', the next line is considered as the continuation of the current line. I Would like to wtite something like this let mut multi = ~; for line in BufferedReader::new(reader).lines() { match line { Ok(l) = { multi