On 2014.09.11 21:26:16 +0200, Christophe Pedretti wrote:
> Hello,
>
> with 0.11.0, this code was ok
>
> pub struct Cursor<'a, 'b> {
> > pStmt : &'b Statement<'a>,
> > error : bool
> > }
You need a bound on the lifetime now, to guarantee that the reference(s)
with lifetime 'a contained in Statement<'a> are valid for at least as
long as the reference with lifetime 'b.
So the struct should now look like this:
pub struct Cursor<'a, 'b: 'a> {
pStmt: &'a Statement<'b>,
error: bool,
}
This is correctly handled now that RFC 49 [1] has been implemented.
The corresponding PR is #16453 [2] and it lists the relevant breaking changes.
Björn
[1] https://github.com/rust-lang/rfcs/pull/192
[2] https://github.com/rust-lang/rust/pull/16453
>
>
> 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
> sql\connection.rs:50 pub struct Cursor<'a, 'b> {
> sql\connection.rs:51 pStmt : &'b Statement<'a>,
> sql\connection.rs:52 error : bool
> sql\connection.rs:53 }
> sql\connection.rs:50:1: 53:2 note: the pointer is valid for the lifetime 'b
> as defined on the struct at 50:0
> sql\connection.rs:50 pub struct Cursor<'a, 'b> {
> sql\connection.rs:51 pStmt : &'b Statement<'a>,
> sql\connection.rs:52 error : bool
> sql\connection.rs:53 }
> sql\connection.rs:50:1: 53:2 note: but the referenced data is only valid
> for the lifetime 'a as defined on the struct at 50:0
> sql\connection.rs:50 pub struct Cursor<'a, 'b> {
> sql\connection.rs:51 pStmt : &'b Statement<'a>,
> sql\connection.rs:52 error : bool
> sql\connection.rs:53 }
> error: aborting due to previous error
>
> why this change ?
> _______________________________________________
> 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